diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-26 05:30:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-26 05:30:35 +0000 |
commit | 4989b842718e0ca1643a906dedda433b9a2c0679 (patch) | |
tree | bbe8d1966d648f64d06ee2e732bd0d30ed8a1b53 /lib/AsmParser/llvmAsmParser.y | |
parent | 5fc30dfe7145d4d02ea2b39337691ad1bf2e9d90 (diff) | |
download | external_llvm-4989b842718e0ca1643a906dedda433b9a2c0679.zip external_llvm-4989b842718e0ca1643a906dedda433b9a2c0679.tar.gz external_llvm-4989b842718e0ca1643a906dedda433b9a2c0679.tar.bz2 |
wrap long lines
Fix PR1358 and test/Assembler/2007-04-25-AssemblerFoldExternWeak.ll, by
creating forward decl globals with linkage extern_weak to defeat implicit
constant folding.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36469 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/llvmAsmParser.y')
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index ab10cc7..14524cb 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -1608,7 +1608,8 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + + STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, *$3); delete $1; delete $3; @@ -1627,7 +1628,8 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr // Check to ensure that Type is not packed if (STy->isPacked()) - GEN_ERROR("Unpacked Initializer to vector type '" + STy->getDescription() + "'"); + GEN_ERROR("Unpacked Initializer to vector type '" + + STy->getDescription() + "'"); $$ = ConstantStruct::get(STy, std::vector<Constant*>()); delete $1; @@ -1746,11 +1748,11 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr GlobalValue *GV; if (const FunctionType *FTy = dyn_cast<FunctionType>(PT->getElementType())) { - GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, + GV = new Function(FTy, GlobalValue::ExternalWeakLinkage, Name, CurModule.CurrentModule); } else { GV = new GlobalVariable(PT->getElementType(), false, - GlobalValue::ExternalLinkage, 0, + GlobalValue::ExternalWeakLinkage, 0, Name, CurModule.CurrentModule); } @@ -2023,7 +2025,8 @@ Definition } GlobalVarAttributes { CurGV = 0; } - | OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal GlobalType ConstVal { + | OptGlobalAssign GVInternalLinkage GVVisibilityStyle ThreadLocal GlobalType + ConstVal { if ($6 == 0) GEN_ERROR("Global value initializer is not a constant"); CurGV = ParseGlobalVariable($1, $2, $3, $5, $6->getType(), $6, $4); @@ -2031,7 +2034,8 @@ Definition } GlobalVarAttributes { CurGV = 0; } - | OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal GlobalType Types { + | OptGlobalAssign GVExternalLinkage GVVisibilityStyle ThreadLocal GlobalType + Types { if (!UpRefs.empty()) GEN_ERROR("Invalid upreference in type: " + (*$6)->getDescription()); CurGV = ParseGlobalVariable($1, $2, $3, $5, *$6, 0, $4); @@ -2041,7 +2045,8 @@ Definition CurGV = 0; CHECK_FOR_ERROR } - | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage ResultTypes SymbolicValueRef { + | OptGlobalAssign GVVisibilityStyle ALIAS AliasLinkage ResultTypes + SymbolicValueRef { std::string Name($1); if (Name.empty()) GEN_ERROR("Alias name cannot be empty") @@ -2060,7 +2065,8 @@ Definition if (V == 0) GEN_ERROR(std::string("Invalid aliasee for alias: ") + $1); if (GlobalValue* Aliasee = dyn_cast<GlobalValue>(V)) { - GlobalAlias* GA = new GlobalAlias(VTy, $4, Name, Aliasee, CurModule.CurrentModule); + GlobalAlias* GA = new GlobalAlias(VTy, $4, Name, Aliasee, + CurModule.CurrentModule); GA->setVisibility($2); InsertValue(GA, CurModule.Values); } else @@ -2228,7 +2234,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')' CurModule.CurrentModule->getFunctionList().push_back(Fn); } else if (!FunctionName.empty() && // Merge with an earlier prototype? (Fn = CurModule.CurrentModule->getFunction(FunctionName))) { - if (Fn->getFunctionType() != FT ) { + if (Fn->getFunctionType() != FT) { // The existing function doesn't have the same type. This is an overload // error. GEN_ERROR("Overload of function '" + FunctionName + "' not permitted."); @@ -2243,7 +2249,7 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')' AI->setName(""); } } else { // Not already defined? - Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, + Fn = new Function(FT, GlobalValue::ExternalWeakLinkage, FunctionName, CurModule.CurrentModule); InsertValue(Fn, CurModule.Values); |