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

Merging parse errors #177

Open
wants to merge 80 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
98f8505
move injected test cases to a separate folder
SlaterLatiao Jan 10, 2022
1edddb6
updated some test cases
SlaterLatiao Jan 12, 2022
daf2de0
updated return values
SlaterLatiao Feb 3, 2022
f1ed96f
updated git ignore
pattersonzUTD Feb 3, 2022
4327729
updated git ignore
pattersonzUTD Feb 3, 2022
349c4a9
added scripts for executing desugared output
pattersonzUTD Feb 3, 2022
392246b
Merge branch 'mergingParseErrors' of github.com:appleseedlab/xtc-dev …
pattersonzUTD Feb 3, 2022
8a4aed6
updated test cases
SlaterLatiao Feb 4, 2022
1cdae12
updated test cases
SlaterLatiao Feb 5, 2022
2af14e5
updated test cases
SlaterLatiao Feb 5, 2022
065016f
merged microbenchmark
pattersonzUTD Feb 7, 2022
8975d23
updated test cases, fixed flex array bug
pattersonzUTD Feb 7, 2022
b3ee4fd
updated test cases
SlaterLatiao Feb 8, 2022
1252ac4
updated code and results of benchmark
pattersonzUTD Feb 12, 2022
f5c8500
added functionality for keeping free/malloc/calloc functions as is, a…
pattersonzUTD Mar 8, 2022
f415138
updated results did infer work
pattersonzUTD Mar 21, 2022
a44a602
update
pattersonzUTD Jun 21, 2022
791c924
changed unsupported semantic actions to parse errors
pattersonzUTD Aug 30, 2022
cd17f03
updated runTest scripts, new results for files
pattersonz Sep 8, 2022
3b5f9e7
updated make-main to take command line args
pattersonzUTD Sep 16, 2022
478f6ee
now checks return type in make-main
pattersonz Sep 16, 2022
169605f
added more line numbers
pattersonz Sep 20, 2022
8c3c6a3
updated keep-mem
pattersonz Sep 29, 2022
e7b95bc
updated grabbing token text and line number results
pattersonz Sep 29, 2022
f69d5d5
added method comments
pattersonz Sep 29, 2022
5908a27
changed static condition defaults to int methods with random return
pattersonz Oct 22, 2022
9261d60
bug fix to static condition default change
pattersonz Oct 22, 2022
c6fc928
fix bug where not all static conditions were methods
pattersonz Oct 23, 2022
0b26fd5
added stdio for file opening and closing
pattersonz Nov 7, 2022
2133aa8
cleanup
pattersonz Nov 30, 2022
7088262
mend
pattersonz Nov 30, 2022
7a9fa19
mend
pattersonz Dec 6, 2022
83bd4fb
added option for BDD printing
pattersonz Dec 7, 2022
0ba6a0a
change SugarC to not simply print bdd/z3 but to fully use one or the …
pattersonz Jan 11, 2023
b7eff74
fix bug where void* was not properly allowed in function calls
pattersonz Jan 23, 2023
98b6ef8
updated function calls to always allow pointer to pointer as a legal …
pattersonz Jan 24, 2023
4848719
split function prototype semantic action to add function name to smyb…
pattersonz Jan 27, 2023
d6e976e
allow functions to pass into function pointers
pattersonz Jan 28, 2023
7bfd10f
mend
pattersonz Jan 28, 2023
d2de25e
mend
pattersonz Jan 29, 2023
a71c8ee
changed subsequent method references to forward referenced structs wi…
pattersonz Jan 31, 2023
3ab1974
mend
pattersonz Jan 31, 2023
b71b726
mend
pattersonz Jan 31, 2023
a13c11d
fix enum equality
pattersonz Feb 2, 2023
38da1b2
dereferencing a forward reference pointer now derefs to a child type
pattersonz Feb 4, 2023
f2b8588
qualified pointers noncompatible with void
pattersonz Feb 6, 2023
140467f
fixed majority of regressions
pattersonz Feb 14, 2023
d38c412
added memset memcpy
pattersonz Feb 14, 2023
5e57326
fixed missing pointers in forward ref transforms
pattersonz Feb 15, 2023
a6f3ddc
added string for clang compile
pattersonz Feb 15, 2023
0bc1b63
added complete node transformation values for declaringlist values
pattersonz Feb 15, 2023
c6e9cbc
functions with prototypes now create multiplexes
pattersonz Feb 20, 2023
ef464c4
added Presence Condition delRefs to functions
pattersonz Feb 20, 2023
bc0dd92
mend
pattersonz Feb 20, 2023
02a09c4
mend
pattersonz Feb 21, 2023
493453d
mend
pattersonz Feb 21, 2023
6f21466
fixed issue with printing enum names and maintaining const
pattersonz Feb 22, 2023
3d9f23b
rewrote how printType works
pattersonz Feb 23, 2023
c4f6a42
mend
pattersonz Feb 23, 2023
634f113
mend
pattersonz Feb 23, 2023
f6a9fba
updated ordering of const and pointers
pattersonz Feb 23, 2023
d9d14ba
reworked type building from declarations, and type printing
pattersonz Feb 26, 2023
5f386d6
fixed function types in printType, changed declaration print name to …
pattersonz Feb 27, 2023
fa0dfb2
additions to mem list
pattersonz Feb 28, 2023
9897fb0
changed hash to be string hash, to remove duplicate conditions
pattersonz Mar 2, 2023
0901388
added functionality for a whitelist of macros to config
pattersonz Mar 14, 2023
f33ac5b
updated grammar to allow for abitrary number of commas at the end of …
pattersonz Mar 15, 2023
d8d331c
sanitize check for symtab errors in declaration inits
pattersonz Mar 15, 2023
a6077fa
fixed duplicate global function declarations when using typeof, fixed…
pattersonz Mar 17, 2023
bfe6180
mend
pattersonz Mar 17, 2023
99935fd
mend
pattersonz Mar 18, 2023
a38992e
add check for empty declaration lsist qualifier
pattersonz Mar 20, 2023
47773ba
fixed assembly expression issue
pattersonz Mar 20, 2023
6d307c9
mend
pattersonz Mar 20, 2023
25cb282
mend
pattersonz Mar 21, 2023
0012e38
mend
pattersonz Mar 21, 2023
953908a
mend
pattersonz Mar 21, 2023
99ff1b1
mend
pattersonz Mar 21, 2023
92d2ad6
mend
pattersonz Mar 21, 2023
3a8c1f0
mend
pattersonz Mar 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ allTests.out
*.Log
*.o
*.pyc
*.plist
/fonda/cpp_testsuite/desugarer/masterTypeCheck/binary
/fonda/cpp_testsuite/desugarer/masterTypeCheck/unary
/fonda/cpp_testsuite/desugarer/masterTypeCheck/other
/fonda/cpp_testsuite/desugarer/masterTypeCheck/other
*.desugared.c
*.desugaredCondHeader.c
126 changes: 126 additions & 0 deletions fonda/cpp_testsuite/desugarer/microbenchmark/autoRunnerResults.txt

Large diffs are not rendered by default.

190 changes: 190 additions & 0 deletions fonda/cpp_testsuite/desugarer/microbenchmark/autorunner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
import os
import sys
import re
import threading
from subprocess import PIPE, Popen

CONDHEADERSTR = 'CondHeader.c'

def getFileList(loc):
fs = []
dirList = [loc]
while dirList:
curDir = dirList.pop(0)
for dirFiles in os.listdir(curDir):
realFile = os.path.abspath(curDir + '/' + dirFiles)
if os.path.exists(realFile) and os.path.isdir(realFile):
dirList.append(realFile)
elif (realFile.endswith('.c') and not realFile.endswith('desugared.c')) and realFile not in fs:
fs.append(realFile)
return fs

def getMacroList(f):
ms = []
o = open(f,'r')
for l in o:
if "ifdef" in l or "elif" in l:
words = (re.sub(' +', ' ', l)).split(' ')
for w in words:
if 'ifdef' in w or ( "elif" in l and "defined" in w):
conf = words[words.index(w)+1]
conf = conf.rstrip().lstrip()
if conf not in ms:
ms.append(conf)
o.close()
return ms

def hasInclude(f):
o = open(f,'r')
bad = False;
for l in o:
if '#' in l and 'include' in l:
bad = True
o.close()
return bad

def runBase(f,ms):
sz = len(ms)
res = []
for i in range(0,2**sz):
defs = ''
for m in ms:
if int(i/(2**ms.index(m)))%2 == 1:
defs += ' -D ' + m + '=1 '
else:
defs += ' -U ' + m + ' '
executeCmd = ' '.join(['gcc',defs,f])
p = Popen(executeCmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if 'error:' in stderr.decode():
res.append('157')
else:
result = os.popen('./a.out; echo $?')
resStr = result.read().strip('\n')
if '\n' in resStr:
resStr = resStr.split('\n')[1]
res.append(resStr)
return res

def getExprList(f):
fi = open(f,'r')
res = []
for l in fi:
if '__static_condition_renaming("__static_condition_default_' in l:
words = l.split('"')
n = {}
n['var'] = words[1]
n['cond'] = words[3]
res.append(n)
fi.close()
return res

def writeHeader(defs,name,el):
fiName = name + CONDHEADERSTR
os.system('rm ' + fiName)
head = open(fiName,'w')
head.write('#include <stdbool.h>\n')
for e in el:
head.write('const bool ')
head.write(e['var'])
head.write('() { return ')
c = e['cond']
for d in defs.keys():
c = c.replace('defined ' + d + ')', '1)' if defs[d] else '0)')
head.write(c)
head.write('; }\n')

def runDesug(f,ms,el):
sz = len(ms)
res = []
for i in range(0,2**sz):
defs = {}
for m in ms:
if int(i/(2**ms.index(m)))%2 == 1:
defs[m] = True
else:
defs[m] = False
writeHeader(defs,f[:len(f)-2],el)
executeCmd = ' '.join(['gcc','functionsHeader.c', f[:len(f)-2] + CONDHEADERSTR,f])
p = Popen(executeCmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if 'error:' in stderr.decode():
res.append('777')
else:
result = os.popen('./a.out; echo $?')
resStr = result.read().strip('\n')
if '\n' in resStr:
resStr = resStr.split('\n')[1]
res.append(resStr)
return res

def comp(expect,reality,ms,f):
size = len(expect)
matches = 0
fails = []
for i in range(0,size):
if expect[i] == reality[i]:
matches = matches + 1
else:
fail = ''
for m in ms:
if int(i/(2**ms.index(m)))%2 == 1:
fail = fail + ' ' + m
fails.append(fail + '::'+expect[i]+'/'+reality[i])
if len(fails) == 0:
return f + ' :: match'
return f + ' :: ' + str(matches) + '/' + str(size) + '\n\t' + str(expect) + '/' + str(reality) + '\n\t' + str(fails)

def printStatus(s):
st = ""
for a in s:
if ':: match' in a:
st += a + "\n"
for a in s:
if ':: match' not in a:
st += a + "\n"
return st

def printRes(s):
res = printStatus(s)
res = "~~~Results~~~\n" + res
ff = open("autoRunnerResults.txt","w")
ff.write(res)
ff.close()
print(res)

def runFiles(fileList,results):
for f in fileList:
absFile = os.path.abspath(f)
hasInc = hasInclude(absFile)
if hasInc:
continue
#get list of macros
macros = getMacroList(absFile)
#run each variant of macros -> store results
baseRes = runBase(absFile,macros)
#desugar file
os.system('rm ' + absFile[:len(absFile)-2]+".desugared.c")
cmd = " ".join(["nohup", "java", "superc.SugarC", "-keep-mem", "-make-main", "-showActions", "-useBDD", absFile, ">", absFile[:len(absFile)-2]+".desugared.c", "2>", absFile[:len(absFile)-2]+".Log"])
os.system(cmd)
if not os.path.exists(absFile[:len(absFile)-2]+".desugared.c"):
results.append(f + " :: did not desug")
continue
#get static condition expressions
expressionList = getExprList(absFile[:len(absFile)-2]+".desugared.c")
#run each variant of macros -> store results
desugRes = runDesug(absFile[:len(absFile)-2]+".desugared.c",macros,expressionList)
#compare results
results.append(comp(baseRes,desugRes,macros,f))


def main():
#get list of files
fileList = getFileList("/home/kisamefishfry/Documents/xtc-dev/fonda/cpp_testsuite/desugarer/microbenchmark/testcases")
#for each file...
results = []
runFiles(fileList,results)
printRes(results)

if __name__ == '__main__':
main()
3 changes: 3 additions & 0 deletions fonda/cpp_testsuite/desugarer/microbenchmark/condHeader.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <stdbool.h>
const bool __static_condition_default_3 = (1);
const bool __static_condition_default_4 = !(1);
Binary file not shown.
17 changes: 17 additions & 0 deletions fonda/cpp_testsuite/desugarer/microbenchmark/functionsHeader.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
void __static_parse_error(char *msg) {
//printf("parse error: %s\n", msg);
exit(-99);
}
void __static_type_error(char *msg) {
//printf("type error: %s\n", msg);
exit(-99);
}
void __static_renaming(char *renaming, char *original) {
//printf("renaming: %s -> %s\n", original, renaming);
}

void __static_condition_renaming(char *expression, char *renaming) {
//printf("condition renaming: %s -> %s\n", expression, renaming);
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
int x
#ifdef A
()
() { return 2;}
#endif
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ int x
#endif
;

#ifdef A
int x () { return 2; }
#endif

int main()
{
struct x *pfd;
if ( ( pfd[2].revents & 0x010 ) && x() == 0 ) {

}
return 3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ struct t {

int main() {
struct s s;
s.z->p = 2;
return s.z->p;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ struct x {

int main() {
struct x x;
x.s = 12;
return x.s;
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading