aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/analyzer.js2
-rw-r--r--src/intertyper.js12
-rw-r--r--src/parseTools.js2
-rw-r--r--tests/cases/quoted.ll35
-rw-r--r--tests/runner.py17
5 files changed, 58 insertions, 10 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 1b46a076..494355c5 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -87,7 +87,7 @@ function analyzer(data, givenTypes) {
function addType(type, data) {
if (type.length == 1) return;
if (data.types[type]) return;
- if (['internal', 'inbounds', 'void'].indexOf(type) != -1) return;
+ if (['internal', 'hidden', 'inbounds', 'void'].indexOf(type) != -1) return;
if (Runtime.isNumberType(type)) return;
// 'blocks': [14 x %struct.X] etc. If this is a pointer, we need
diff --git a/src/intertyper.js b/src/intertyper.js
index 6b52d5c7..932acbe5 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -162,8 +162,12 @@ function intertyper(data, parseFunctions) {
case '"':
if (totalEnclosing == 0) {
if (quotes == 0) {
- makeToken(curr);
- curr = '"';
+ if (curr == '@' || curr == '%') {
+ curr += '"';
+ } else {
+ makeToken(curr);
+ curr = '"';
+ }
} else {
makeToken(curr + '"');
curr = '';
@@ -328,7 +332,7 @@ function intertyper(data, parseFunctions) {
} else {
// variable
var ident = item.tokens[0].text;
- while (item.tokens[2].text in set('private', 'constant', 'appending', 'global', 'weak_odr', 'internal', 'linkonce', 'linkonce_odr', 'weak'))
+ while (item.tokens[2].text in set('private', 'constant', 'appending', 'global', 'weak_odr', 'internal', 'linkonce', 'linkonce_odr', 'weak', 'hidden'))
item.tokens.splice(2, 1);
var ret = {
__result__: true,
@@ -366,7 +370,7 @@ function intertyper(data, parseFunctions) {
funcHeader = substrate.addZyme('FuncHeader', {
processItem: function(item) {
item.tokens = item.tokens.filter(function(token) {
- return ['noalias', 'available_externally', 'weak', 'internal', 'signext', 'zeroext', 'nounwind', 'define', 'linkonce_odr', 'inlinehint', '{', 'fastcc'].indexOf(token.text) == -1;
+ return ['noalias', 'available_externally', 'weak', 'internal', 'hidden', 'signext', 'zeroext', 'nounwind', 'define', 'linkonce_odr', 'inlinehint', '{', 'fastcc'].indexOf(token.text) == -1;
});
var ret = [{
__result__: true,
diff --git a/src/parseTools.js b/src/parseTools.js
index 542f97dd..1901b3fc 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -56,7 +56,7 @@ function toNiceIdent(ident) {
assert(ident);
if (parseFloat(ident) == ident) return ident;
if (ident == 'null') return '0'; // see parseNumerical
- return ident.replace(/[" \.@%:<>,\*\[\]-]/g, '_');
+ return ident.replace(/["\\ \.@%:<>,\*\[\]-]/g, '_');
}
function isStructPointerType(type) {
diff --git a/tests/cases/quoted.ll b/tests/cases/quoted.ll
new file mode 100644
index 00000000..5bd8dba8
--- /dev/null
+++ b/tests/cases/quoted.ll
@@ -0,0 +1,35 @@
+; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
+target triple = "i386-pc-linux-gnu"
+
+@.str = private constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1]
+
+; [#uses=2]
+define void @"\01_Z5hellov"() {
+entry:
+ %0 = call i32 @puts(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ br label %return
+
+return: ; preds = %entry
+ ret void
+}
+
+; [#uses=1]
+declare i32 @puts(i8*)
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32 ; [#uses=2]
+ %0 = alloca i32 ; [#uses=2]
+ %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
+ call void @"\01_Z5hellov"()
+ store i32 0, i32* %0, align 4
+ %1 = load i32* %0, align 4 ; [#uses=1]
+ store i32 %1, i32* %retval, align 4
+ br label %return
+
+return: ; preds = %entry
+ %retval1 = load i32* %retval ; [#uses=1]
+ ret i32 %retval1
+}
diff --git a/tests/runner.py b/tests/runner.py
index 2a988f8c..d35afa86 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -99,11 +99,10 @@ class RunnerCore(unittest.TestCase):
if 'benchmark' not in sys.argv:
class T(RunnerCore): # Short name, to make it more fun to use manually on the commandline
## Does a complete test - builds, runs, checks output, etc.
- def do_test(self, src, expected_output, args=[], output_nicerizer=None, output_processor=None, no_build=False, main_file=None, js_engines=None, post_build=None):
- if not no_build:
- print 'Running test:', inspect.stack()[1][3].replace('test_', ''), '[%s%s]' % (COMPILER.split(os.sep)[-1], ',reloop&optimize' if RELOOP else '')
+ def do_test(self, src, expected_output, args=[], output_nicerizer=None, output_processor=None, no_build=False, main_file=None, js_engines=None, post_build=None, basename='src.cpp'):
+ print 'Running test:', inspect.stack()[1][3].replace('test_', ''), '[%s%s]' % (COMPILER.split(os.sep)[-1], ',reloop&optimize' if RELOOP else '')
dirname = self.get_dir()
- filename = os.path.join(dirname, 'src.cpp')
+ filename = os.path.join(dirname, basename)
if not no_build:
self.build(src, dirname, filename, main_file=main_file)
@@ -1020,6 +1019,16 @@ if 'benchmark' not in sys.argv:
no_build=True,
js_engines=[V8_ENGINE]) # mozilla bug XXX
+ ### Test cases in separate files
+
+ def test_cases(self):
+ for name in os.listdir(path_from_root(['tests', 'cases'])):
+ shortname = name.replace('.ll', '')
+ filename = os.path.join(self.get_dir(), shortname)
+ shutil.copy(path_from_root(['tests', 'cases', name]), filename+'.o.ll')
+ self.do_emscripten(filename)
+ self.do_test(None, 'hello, world!', no_build=True, basename=shortname)
+
### Integration tests
def test_scriptaclass(self):