From: Reid Spencer Date: Wed, 21 Mar 2007 17:26:41 +0000 (+0000) Subject: For PR1243: X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=91a9d54d9af3be5ac28f92fe49b5a2fcf22b9bb1;p=oota-llvm.git For PR1243: Okay, really fix it this time. Make sure the CurFun.Linkage is set early and consolidate some duplicate code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35236 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-upgrade/UpgradeParser.y b/tools/llvm-upgrade/UpgradeParser.y index 9dabc23d751..ab06bb4789b 100644 --- a/tools/llvm-upgrade/UpgradeParser.y +++ b/tools/llvm-upgrade/UpgradeParser.y @@ -2936,25 +2936,21 @@ FunctionHeaderH CurModule.RenameMap[Key] = Conflict->getName(); Fn = new Function(FT, CurFun.Linkage, FunctionName, M); InsertValue(Fn, CurModule.Values); - } else if (CurFun.Linkage == GlobalValue::InternalLinkage) { - // We can safely rename the function we're defining - std::string NewName = makeNameUnique(FunctionName); - Fn = new Function(FT, CurFun.Linkage, NewName, M); - InsertValue(Fn, CurModule.Values); - RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); - CurModule.RenameMap[Key] = NewName; - } else { + } else { // We can't quietly rename either of these things, but we must - // rename one of them. Generate a warning about the renaming and - // elect to rename the thing we're now defining. + // rename one of them. Only if the function's linkage is internal can + // we forgo a warning message about the renamed function. std::string NewName = makeNameUnique(FunctionName); - warning("Renaming function '" + FunctionName + "' as '" + NewName + - "' may cause linkage errors"); + if (CurFun.Linkage != GlobalValue::InternalLinkage) { + warning("Renaming function '" + FunctionName + "' as '" + NewName + + "' may cause linkage errors"); + } + // Elect to rename the thing we're now defining. Fn = new Function(FT, CurFun.Linkage, NewName, M); InsertValue(Fn, CurModule.Values); RenameMapKey Key = makeRenameMapKey(FunctionName, PFT, ID.S); CurModule.RenameMap[Key] = NewName; - } + } } else { // There's no conflict, just define the function Fn = new Function(FT, CurFun.Linkage, FunctionName, M); @@ -3005,7 +3001,7 @@ BEGIN ; FunctionHeader - : OptLinkage FunctionHeaderH BEGIN { + : OptLinkage { CurFun.Linkage = $1; } FunctionHeaderH BEGIN { $$ = CurFun.CurrentFunction; // Make sure that we keep track of the linkage type even if there was a