[llvm] r260941 - Do some refactoring in constant generation in the C API echo test. NFC
Amaury Sechet via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 15 23:33:24 PST 2016
Author: deadalnix
Date: Tue Feb 16 01:33:23 2016
New Revision: 260941
URL: http://llvm.org/viewvc/llvm-project?rev=260941&view=rev
Log:
Do some refactoring in constant generation in the C API echo test. NFC
Modified:
llvm/trunk/tools/llvm-c-test/echo.cpp
Modified: llvm/trunk/tools/llvm-c-test/echo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-c-test/echo.cpp?rev=260941&r1=260940&r2=260941&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-c-test/echo.cpp (original)
+++ llvm/trunk/tools/llvm-c-test/echo.cpp Tue Feb 16 01:33:23 2016
@@ -221,14 +221,12 @@ LLVMValueRef clone_constant(LLVMValueRef
const char *Name = LLVMGetValueName(Cst);
// Try function
- LLVMValueRef Dst = LLVMGetNamedFunction(M, Name);
- if (Dst != nullptr)
- return Dst;
+ if (LLVMIsAFunction(Cst))
+ return LLVMGetNamedFunction(M, Name);
// Try global variable
- Dst = LLVMGetNamedGlobal(M, Name);
- if (Dst != nullptr)
- return Dst;
+ if (LLVMIsAGlobalVariable(Cst))
+ return LLVMGetNamedGlobal(M, Name);
fprintf(stderr, "Could not find @%s\n", Name);
exit(-1);
@@ -243,8 +241,12 @@ LLVMValueRef clone_constant(LLVMValueRef
if (LLVMIsUndef(Cst))
return LLVMGetUndef(TypeCloner(M).Clone(Cst));
- // This kind of constant is not supported.
- report_fatal_error("Unsupported contant type");
+ // This kind of constant is not supported
+ if (!LLVMIsAConstantExpr(Cst))
+ report_fatal_error("Expected a constant expression");
+
+ // At this point, it must be a constant expression
+ report_fatal_error("ConstantExpression are not supported");
}
struct FunCloner {
More information about the llvm-commits
mailing list