[llvm-commits] [llvm] r91318 - /llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
Chris Lattner
sabre at nondot.org
Mon Dec 14 11:34:33 PST 2009
Author: lattner
Date: Mon Dec 14 13:34:32 2009
New Revision: 91318
URL: http://llvm.org/viewvc/llvm-project?rev=91318&view=rev
Log:
fix an obvious bug found by clang++ and collapse a redundant if.
Here's the diagnostic from clang:
/Volumes/Data/dgregor/Projects/llvm/lib/Target/CppBackend/CPPBackend.cpp:989:23: warning: 'gv' is always NULL in this context
printConstant(gv);
^
1 diagnostic generated.
Modified:
llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=91318&r1=91317&r2=91318&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original)
+++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon Dec 14 13:34:32 2009
@@ -976,21 +976,20 @@
nl(Out);
printType(GV->getType());
if (GV->hasInitializer()) {
- Constant* Init = GV->getInitializer();
+ Constant *Init = GV->getInitializer();
printType(Init->getType());
- if (Function* F = dyn_cast<Function>(Init)) {
+ if (Function *F = dyn_cast<Function>(Init)) {
nl(Out)<< "/ Function Declarations"; nl(Out);
printFunctionHead(F);
} else if (GlobalVariable* gv = dyn_cast<GlobalVariable>(Init)) {
nl(Out) << "// Global Variable Declarations"; nl(Out);
printVariableHead(gv);
- } else {
- nl(Out) << "// Constant Definitions"; nl(Out);
- printConstant(gv);
- }
- if (GlobalVariable* gv = dyn_cast<GlobalVariable>(Init)) {
+
nl(Out) << "// Global Variable Definitions"; nl(Out);
printVariableBody(gv);
+ } else {
+ nl(Out) << "// Constant Definitions"; nl(Out);
+ printConstant(Init);
}
}
}
More information about the llvm-commits
mailing list