llvm.org GIT mirror llvm / f1671f6
Do some refactoring in constant generation in the C API echo test. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260941 91177308-0d34-0410-b5e6-96231b3b80d8 Amaury Sechet 4 years ago
1 changed file(s) with 10 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
220220 const char *Name = LLVMGetValueName(Cst);
221221
222222 // Try function
223 LLVMValueRef Dst = LLVMGetNamedFunction(M, Name);
224 if (Dst != nullptr)
225 return Dst;
223 if (LLVMIsAFunction(Cst))
224 return LLVMGetNamedFunction(M, Name);
226225
227226 // Try global variable
228 Dst = LLVMGetNamedGlobal(M, Name);
229 if (Dst != nullptr)
230 return Dst;
227 if (LLVMIsAGlobalVariable(Cst))
228 return LLVMGetNamedGlobal(M, Name);
231229
232230 fprintf(stderr, "Could not find @%s\n", Name);
233231 exit(-1);
242240 if (LLVMIsUndef(Cst))
243241 return LLVMGetUndef(TypeCloner(M).Clone(Cst));
244242
245 // This kind of constant is not supported.
246 report_fatal_error("Unsupported contant type");
243 // This kind of constant is not supported
244 if (!LLVMIsAConstantExpr(Cst))
245 report_fatal_error("Expected a constant expression");
246
247 // At this point, it must be a constant expression
248 report_fatal_error("ConstantExpression are not supported");
247249 }
248250
249251 struct FunCloner {