Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use ubuntu latest #1615

Merged
merged 8 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
return cflGraph;
}

CFLGraph * CFLGraphBuilder::buildFromDot(std::string fileName, GrammarBase *grammar, BuildDirection direction)
CFLGraph *CFLGraphBuilder::buildFromDot(std::string fileName, GrammarBase *grammar, BuildDirection direction)

Check warning on line 196 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L196

Added line #L196 was not covered by tests
{
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

Check warning on line 231 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L231

Added line #L231 was not covered by tests
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);

Check warning on line 238 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L236-L238

Added lines #L236 - L238 were not covered by tests

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

Check warning on line 242 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L241-L242

Added lines #L241 - L242 were not covered by tests

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

Check warning on line 245 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L244-L245

Added lines #L244 - L245 were not covered by tests

if (labelToKindMap.find(label) != labelToKindMap.end())
{
cflGraph->addCFLEdge(src, dst, labelToKindMap[label]);

Check warning on line 249 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L249

Added line #L249 was not covered by tests
}
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++});

Check warning on line 255 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L255

Added line #L255 was not covered by tests
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) +

Check warning on line 260 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L260

Added line #L260 was not covered by tests
" sym cannot be found in grammar. Please correct the input dot or set --flexsymmap.";
SVFUtil::errMsg(msg);

Check warning on line 262 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L262

Added line #L262 was not covered by tests
std::cout << msg;
abort();

Check warning on line 264 in svf/lib/CFL/CFLGraphBuilder.cpp

View check run for this annotation

Codecov / codecov/patch

svf/lib/CFL/CFLGraphBuilder.cpp#L264

Added line #L264 was not covered by tests
}
}
}

inputFile.close();
return cflGraph;
}
Expand All @@ -247,7 +277,6 @@
return cflGraph;
}


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


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