[llvm-commits] CVS: llvm/tools/llvm-upgrade/ParserInternals.h UpgradeParser.y

Reid Spencer reid at x10sys.com
Tue Dec 5 11:18:43 PST 2006



Changes in directory llvm/tools/llvm-upgrade:

ParserInternals.h updated: 1.7 -> 1.8
UpgradeParser.y updated: 1.17 -> 1.18
---
Log message:

For PR645: http://llvm.org/PR645 :
Keep track of global constant and variable definitions for eventual use
in resolving conflicts between global and local symbol usage.


---
Diffs of the changes:  (+19 -4)

 ParserInternals.h |    6 ++++++
 UpgradeParser.y   |   17 +++++++++++++----
 2 files changed, 19 insertions(+), 4 deletions(-)


Index: llvm/tools/llvm-upgrade/ParserInternals.h
diff -u llvm/tools/llvm-upgrade/ParserInternals.h:1.7 llvm/tools/llvm-upgrade/ParserInternals.h:1.8
--- llvm/tools/llvm-upgrade/ParserInternals.h:1.7	Sat Dec  2 14:19:56 2006
+++ llvm/tools/llvm-upgrade/ParserInternals.h	Tue Dec  5 13:18:29 2006
@@ -60,6 +60,12 @@
 
   void destroy() const { delete newTy; }
 
+  TypeInfo clone() const { 
+    TypeInfo result = *this; 
+    result.newTy = new std::string(*newTy);
+    return result;
+  }
+
   Types getElementType() const { return elemTy; }
 
   bool isSigned() const {


Index: llvm/tools/llvm-upgrade/UpgradeParser.y
diff -u llvm/tools/llvm-upgrade/UpgradeParser.y:1.17 llvm/tools/llvm-upgrade/UpgradeParser.y:1.18
--- llvm/tools/llvm-upgrade/UpgradeParser.y:1.17	Sun Dec  3 01:10:26 2006
+++ llvm/tools/llvm-upgrade/UpgradeParser.y	Tue Dec  5 13:18:29 2006
@@ -39,6 +39,7 @@
 static TypeVector EnumeratedTypes;
 typedef std::map<std::string,TypeInfo> TypeMap;
 static TypeMap NamedTypes;
+static TypeMap Globals;
 
 void destroy(ValueList* VL) {
   while (!VL->empty()) {
@@ -777,29 +778,37 @@
     $$ = 0;
   }
   | ConstPool OptAssign OptLinkage GlobalType ConstVal  GlobalVarAttributes {
-    if (!$2->empty())
+    if (!$2->empty()) {
       *O << *$2 << " = ";
+      Globals[*$2] = $5.type.clone();
+    }
     *O << *$3 << " " << *$4 << " " << *$5.cnst << " " << *$6 << "\n";
     delete $2; delete $3; delete $4; $5.destroy(); delete $6; 
     $$ = 0;
   }
   | ConstPool OptAssign External GlobalType Types  GlobalVarAttributes {
-    if (!$2->empty())
+    if (!$2->empty()) {
       *O << *$2 << " = ";
+      Globals[*$2] = $5.clone();
+    }
     *O <<  *$3 << " " << *$4 << " " << *$5.newTy << " " << *$6 << "\n";
     delete $2; delete $3; delete $4; $5.destroy(); delete $6;
     $$ = 0;
   }
   | ConstPool OptAssign DLLIMPORT GlobalType Types  GlobalVarAttributes {
-    if (!$2->empty())
+    if (!$2->empty()) {
       *O << *$2 << " = ";
+      Globals[*$2] = $5.clone();
+    }
     *O << *$3 << " " << *$4 << " " << *$5.newTy << " " << *$6 << "\n";
     delete $2; delete $3; delete $4; $5.destroy(); delete $6;
     $$ = 0;
   }
   | ConstPool OptAssign EXTERN_WEAK GlobalType Types  GlobalVarAttributes {
-    if (!$2->empty())
+    if (!$2->empty()) {
       *O << *$2 << " = ";
+      Globals[*$2] = $5.clone();
+    }
     *O << *$3 << " " << *$4 << " " << *$5.newTy << " " << *$6 << "\n";
     delete $2; delete $3; delete $4; $5.destroy(); delete $6;
     $$ = 0;






More information about the llvm-commits mailing list