diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-08-21 03:01:12 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-08-21 03:01:12 +0000 |
commit | 3ec0bafda37da00aac370e24f9fff9efb90861d2 (patch) | |
tree | ffb95a2c7d96fdc378c4ebf17076dee48213c041 /lib/CodeGen/CGExpr.cpp | |
parent | 5cf8bfec711116b3c4acc70a00717b2e119e7550 (diff) |
IRgen: Eliminate EmitPredefinedFunctionName(), it doesn't need to be factored out.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111715 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index f0eec03755..13f3c26d03 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1275,47 +1275,46 @@ LValue CodeGenFunction::EmitObjCEncodeExprLValue(const ObjCEncodeExpr *E) { } -LValue CodeGenFunction::EmitPredefinedFunctionName(unsigned Type) { - std::string GlobalVarName; +LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { + switch (E->getIdentType()) { + default: + return EmitUnsupportedLValue(E, "predefined expression"); - switch (Type) { - default: assert(0 && "Invalid type"); case PredefinedExpr::Func: - GlobalVarName = "__func__."; - break; case PredefinedExpr::Function: - GlobalVarName = "__FUNCTION__."; - break; - case PredefinedExpr::PrettyFunction: - GlobalVarName = "__PRETTY_FUNCTION__."; - break; - } + case PredefinedExpr::PrettyFunction: { + unsigned Type = E->getIdentType(); + std::string GlobalVarName; + + switch (Type) { + default: assert(0 && "Invalid type"); + case PredefinedExpr::Func: + GlobalVarName = "__func__."; + break; + case PredefinedExpr::Function: + GlobalVarName = "__FUNCTION__."; + break; + case PredefinedExpr::PrettyFunction: + GlobalVarName = "__PRETTY_FUNCTION__."; + break; + } - llvm::StringRef FnName = CurFn->getName(); - if (FnName.startswith("\01")) - FnName = FnName.substr(1); - GlobalVarName += FnName; + llvm::StringRef FnName = CurFn->getName(); + if (FnName.startswith("\01")) + FnName = FnName.substr(1); + GlobalVarName += FnName; - const Decl *CurDecl = CurCodeDecl; - if (CurDecl == 0) - CurDecl = getContext().getTranslationUnitDecl(); - - std::string FunctionName = - PredefinedExpr::ComputeName((PredefinedExpr::IdentType)Type, CurDecl); + const Decl *CurDecl = CurCodeDecl; + if (CurDecl == 0) + CurDecl = getContext().getTranslationUnitDecl(); - llvm::Constant *C = - CGM.GetAddrOfConstantCString(FunctionName, GlobalVarName.c_str()); - return LValue::MakeAddr(C, Qualifiers()); -} + std::string FunctionName = + PredefinedExpr::ComputeName((PredefinedExpr::IdentType)Type, CurDecl); -LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) { - switch (E->getIdentType()) { - default: - return EmitUnsupportedLValue(E, "predefined expression"); - case PredefinedExpr::Func: - case PredefinedExpr::Function: - case PredefinedExpr::PrettyFunction: - return EmitPredefinedFunctionName(E->getIdentType()); + llvm::Constant *C = + CGM.GetAddrOfConstantCString(FunctionName, GlobalVarName.c_str()); + return LValue::MakeAddr(C, Qualifiers()); + } } } |