diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-12-05 19:18:29 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-12-05 19:18:29 +0000 |
commit | 999b2df114e28ac8de0384f9742fad8062ad6772 (patch) | |
tree | 00cd881eeae687794db7af85bf640f4ba346949e /tools | |
parent | 9eef56f53240a79c07acdd48c647b3e925aa984a (diff) | |
download | external_llvm-999b2df114e28ac8de0384f9742fad8062ad6772.zip external_llvm-999b2df114e28ac8de0384f9742fad8062ad6772.tar.gz external_llvm-999b2df114e28ac8de0384f9742fad8062ad6772.tar.bz2 |
For PR645:
Keep track of global constant and variable definitions for eventual use
in resolving conflicts between global and local symbol usage.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32234 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-upgrade/ParserInternals.h | 6 | ||||
-rw-r--r-- | tools/llvm-upgrade/UpgradeParser.y | 17 |
2 files changed, 19 insertions, 4 deletions
diff --git a/tools/llvm-upgrade/ParserInternals.h b/tools/llvm-upgrade/ParserInternals.h index df9d2a8..7fe022e 100644 --- a/tools/llvm-upgrade/ParserInternals.h +++ b/tools/llvm-upgrade/ParserInternals.h @@ -60,6 +60,12 @@ struct TypeInfo { 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 { diff --git a/tools/llvm-upgrade/UpgradeParser.y b/tools/llvm-upgrade/UpgradeParser.y index 8aa2beb..fd1c293 100644 --- a/tools/llvm-upgrade/UpgradeParser.y +++ b/tools/llvm-upgrade/UpgradeParser.y @@ -39,6 +39,7 @@ typedef std::vector<TypeInfo> TypeVector; 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 @@ ConstPool : ConstPool OptAssign TYPE TypesV { $$ = 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; |