[cfe-commits] r93226 - /cfe/trunk/utils/VtableTest/gen.cc
Mike Stump
mrs at apple.com
Mon Jan 11 19:01:18 PST 2010
Author: mrs
Date: Mon Jan 11 21:01:18 2010
New Revision: 93226
URL: http://llvm.org/viewvc/llvm-project?rev=93226&view=rev
Log:
Add covariance tester.
Modified:
cfe/trunk/utils/VtableTest/gen.cc
Modified: cfe/trunk/utils/VtableTest/gen.cc
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/VtableTest/gen.cc?rev=93226&r1=93225&r2=93226&view=diff
==============================================================================
--- cfe/trunk/utils/VtableTest/gen.cc (original)
+++ cfe/trunk/utils/VtableTest/gen.cc Mon Jan 11 21:01:18 2010
@@ -3,9 +3,10 @@
#define N_FIELDS 7
#define N_FUNCS 128
-#define FUNCSPACING 10
-#define N_STRUCTS 300 /* 1280 */
-#define N_BASES 30
+#define FUNCSPACING 20
+#define N_STRUCTS 180 /* 1280 */
+#define N_BASES 6
+#define COVARIANT 0
const char *simple_types[] = { "bool", "char", "short", "int", "float",
"double", "long double", "wchar_t", "void *",
@@ -84,15 +85,19 @@
// polymorphic = true;
base_type = 3;
}
- switch (random()%8) {
+ // PARAM: 1/4 are public, 1/8 are privare, 1/8 are protected, the reset, default
+ int base_protection = 0;
+ if (!COVARIANT)
+ base_protection = random()%8;
+ switch (base_protection) {
case 0:
case 1:
+ g("public "); break;
case 2:
case 3:
- break;
case 4:
case 5:
- g("public "); break;
+ break;
case 6:
g("private "); break;
case 7:
@@ -129,7 +134,18 @@
for (int i = 0; i < n_funcs; ++i) {
int fn = old_func + random() % FUNCSPACING + 1;
funcs[i] = fn;
- g(" virtual void fun"); g(fn); g("(char *t) { mix(\"vfn this offset\", (char *)this - t); mix(\"vfn uuid\", "); g(++uuid); gl("); }");
+ int rettype = 0;
+ if (COVARIANT)
+ rettype = s;
+ if (rettype) {
+ g(" virtual s"); g(rettype); g("* fun");
+ } else
+ g(" virtual void fun");
+ g(fn); g("(char *t) { mix(\"vfn this offset\", (char *)this - t); mix(\"vfn uuid\", "); g(++uuid);
+ if (rettype)
+ gl("); return 0; }");
+ else
+ gl("); }");
funcs_present[s][fn] = 1;
final_override[s][fn] = s;
old_func = fn;
@@ -183,7 +199,18 @@
funcs[n_funcs++] = fn;
if (n_funcs == (N_FUNCS*FUNCSPACING-1))
abort();
- g(" virtual void fun"); g(fn); g("(char *t) { mix(\"vfn this offset\", (char *)this - t); mix(\"vfn uuid\", "); g(++uuid); gl("); }");
+ int rettype = 0;
+ if (COVARIANT)
+ rettype = s;
+ if (rettype) {
+ g(" virtual s"); g(rettype); g("* fun");
+ } else
+ g(" virtual void fun");
+ g(fn); g("(char *t) { mix(\"vfn this offset\", (char *)this - t); mix(\"vfn uuid\", "); g(++uuid);
+ if (rettype)
+ gl("); return 0; }");
+ else
+ gl("); }");
funcs_present[s][fn] = 1;
final_override[s][fn] = s;
}
More information about the cfe-commits
mailing list