Don't emit type declarations for extern'ed globals in generated header files.

This actually wasn't a good idea, since we'd like ispc programs to be able to
have varying globals that it uses internally among ispc code, without having
errors about varying globals when generating headers.

Issue #214.
This commit is contained in:
Matt Pharr
2012-04-03 05:36:21 -07:00
parent 05d1b06eeb
commit dc09d46bf4

View File

@@ -1,5 +1,5 @@
/* /*
Copyright (c) 2010-2011, Intel Corporation Copyright (c) 2010-2012, Intel Corporation
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@@ -1027,21 +1027,6 @@ lPrintFunctionDeclarations(FILE *file, const std::vector<Symbol *> &funcs) {
} }
static void
lPrintExternGlobals(FILE *file, const std::vector<Symbol *> &externGlobals) {
for (unsigned int i = 0; i < externGlobals.size(); ++i) {
Symbol *sym = externGlobals[i];
if (lRecursiveCheckValidParamType(sym->type))
Warning(sym->pos, "Not emitting declaration for symbol \"%s\" into "
"generated header file since it (or some of its members) "
"has types that are illegal in exported symbols.",
sym->name.c_str());
else
fprintf(file, "extern %s;\n", sym->type->GetCDeclaration(sym->name).c_str());
}
}
static bool static bool
lIsExported(const Symbol *sym) { lIsExported(const Symbol *sym) {
const FunctionType *ft = dynamic_cast<const FunctionType *>(sym->type); const FunctionType *ft = dynamic_cast<const FunctionType *>(sym->type);
@@ -1058,12 +1043,6 @@ lIsExternC(const Symbol *sym) {
} }
static bool
lIsExternGlobal(const Symbol *sym) {
return sym->storageClass == SC_EXTERN || sym->storageClass == SC_EXTERN_C;
}
bool bool
Module::writeHeader(const char *fn) { Module::writeHeader(const char *fn) {
FILE *f = fopen(fn, "w"); FILE *f = fopen(fn, "w");
@@ -1116,13 +1095,6 @@ Module::writeHeader(const char *fn) {
lGetExportedParamTypes(externCFuncs, &exportedStructTypes, lGetExportedParamTypes(externCFuncs, &exportedStructTypes,
&exportedEnumTypes, &exportedVectorTypes); &exportedEnumTypes, &exportedVectorTypes);
// And do the same for the 'extern' globals
std::vector<Symbol *> externGlobals;
symbolTable->GetMatchingVariables(lIsExternGlobal, &externGlobals);
for (unsigned int i = 0; i < externGlobals.size(); ++i)
lGetExportedTypes(externGlobals[i]->type, &exportedStructTypes,
&exportedEnumTypes, &exportedVectorTypes);
// And print them // And print them
lEmitVectorTypedefs(exportedVectorTypes, f); lEmitVectorTypedefs(exportedVectorTypes, f);
lEmitEnumDecls(exportedEnumTypes, f); lEmitEnumDecls(exportedEnumTypes, f);
@@ -1149,15 +1121,6 @@ Module::writeHeader(const char *fn) {
// end namespace // end namespace
fprintf(f, "\n#ifdef __cplusplus\n}\n#endif // __cplusplus\n"); fprintf(f, "\n#ifdef __cplusplus\n}\n#endif // __cplusplus\n");
// and only now emit externs for globals, outside of the ispc namespace
if (externGlobals.size() > 0) {
fprintf(f, "\n");
fprintf(f, "///////////////////////////////////////////////////////////////////////////\n");
fprintf(f, "// Globals declared \"extern\" from ispc code\n");
fprintf(f, "///////////////////////////////////////////////////////////////////////////\n");
lPrintExternGlobals(f, externGlobals);
}
// end guard // end guard
fprintf(f, "\n#endif // %s\n", guard.c_str()); fprintf(f, "\n#endif // %s\n", guard.c_str());