[llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp
vadve at cs.uiuc.edu
vadve at cs.uiuc.edu
Tue Sep 17 06:51:01 PDT 2002
Changes in directory llvm/lib/CWriter:
Writer.cpp updated: 1.44 -> 1.45
---
Log message:
Don't print global variable definitions twice! Sun's pathetic compiler
never complained about this.
---
Diffs of the changes:
Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.44 llvm/lib/CWriter/Writer.cpp:1.45
--- llvm/lib/CWriter/Writer.cpp:1.44 Sun Sep 15 16:51:04 2002
+++ llvm/lib/CWriter/Writer.cpp Tue Sep 17 06:50:38 2002
@@ -522,11 +522,13 @@
// Global variable declarations...
if (!M->gempty()) {
- Out << "\n/* Global Variable Declarations */\n";
+ Out << "\n/* External Global Variable Declarations */\n";
for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
- Out << (I->hasExternalLinkage() ? "extern " : "static ");
- printType(I->getType()->getElementType(), getValueName(I));
- Out << ";\n";
+ if (I->hasExternalLinkage()) {
+ Out << "extern ";
+ printType(I->getType()->getElementType(), getValueName(I));
+ Out << ";\n";
+ }
}
}
@@ -539,11 +541,13 @@
}
}
- // Output the global variable contents...
+ // Output the global variable definitions and contents...
if (!M->gempty()) {
- Out << "\n\n/* Global Data */\n";
+ Out << "\n\n/* Global Variable Definitions and Initialization */\n";
for (Module::giterator I = M->gbegin(), E = M->gend(); I != E; ++I) {
- if (I->hasInternalLinkage()) Out << "static ";
+ if (I->hasExternalLinkage())
+ continue; // printed above!
+ Out << "static ";
printType(I->getType()->getElementType(), getValueName(I));
if (I->hasInitializer()) {
More information about the llvm-commits
mailing list