[llvm-commits] [dragonegg] r97397 - /dragonegg/trunk/llvm-debug.cpp
Duncan Sands
baldrick at free.fr
Sun Feb 28 05:37:05 PST 2010
Author: baldrick
Date: Sun Feb 28 07:37:05 2010
New Revision: 97397
URL: http://llvm.org/viewvc/llvm-project?rev=97397&view=rev
Log:
Port commit 96543 (dpatel) from llvm-gcc:
Tidy up identification of "this" pointer argument and its type.
Corresponding test case is test/FrontendC++/2010-02-17-DbgArtificialArg.cpp
Modified:
dragonegg/trunk/llvm-debug.cpp
Modified: dragonegg/trunk/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=97397&r1=97396&r2=97397&view=diff
==============================================================================
--- dragonegg/trunk/llvm-debug.cpp (original)
+++ dragonegg/trunk/llvm-debug.cpp Sun Feb 28 07:37:05 2010
@@ -405,10 +405,13 @@
// Construct variable.
DIScope VarScope = DIScope(cast<MDNode>(RegionStack.back()));
+ DIType Ty = getOrCreateType(type);
+ if (DECL_ARTIFICIAL (decl))
+ Ty = DebugFactory.CreateArtificialType(Ty);
llvm::DIVariable D =
DebugFactory.CreateVariable(Tag, VarScope,
Name, getOrCreateCompileUnit(Loc.file),
- Loc.line, getOrCreateType(type));
+ Loc.line, Ty);
// Insert an llvm.dbg.declare into the current block.
Instruction *Call = DebugFactory.InsertDeclare(AI, D,
@@ -521,6 +524,21 @@
0, 0, Encoding);
}
+/// isArtificialArgumentType - Return true if arg_type represents artificial,
+/// i.e. "this" in c++, argument.
+static bool isArtificialArgumentType(tree arg_type, tree method_type) {
+ if (TREE_CODE (method_type) != METHOD_TYPE) return false;
+ if (TREE_CODE (arg_type) != POINTER_TYPE) return false;
+ if (TREE_TYPE (arg_type) == TYPE_METHOD_BASETYPE (method_type))
+ return true;
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (arg_type))
+ && TYPE_MAIN_VARIANT (TREE_TYPE (arg_type)) != TREE_TYPE (arg_type)
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (arg_type))
+ == TYPE_METHOD_BASETYPE (method_type)))
+ return true;
+ return false;
+}
+
/// createMethodType - Create MethodType.
DIType DebugInfo::createMethodType(tree type) {
@@ -547,18 +565,18 @@
EltTys.push_back(getOrCreateType(TREE_TYPE(type)));
// Set up remainder of arguments.
+ bool ProcessedFirstArg = false;
for (tree arg = TYPE_ARG_TYPES(type); arg; arg = TREE_CHAIN(arg)) {
tree formal_type = TREE_VALUE(arg);
if (formal_type == void_type_node) break;
llvm::DIType FormalType = getOrCreateType(formal_type);
- if (TREE_CODE (type) == METHOD_TYPE
- && TREE_CODE (formal_type) == POINTER_TYPE
- && TREE_TYPE (formal_type) == TYPE_METHOD_BASETYPE (type)) {
+ if (!ProcessedFirstArg && isArtificialArgumentType(formal_type, type)) {
DIType AFormalType = DebugFactory.CreateArtificialType(FormalType);
EltTys.push_back(AFormalType);
- TypeCache[formal_type] = WeakVH(AFormalType.getNode());
} else
EltTys.push_back(FormalType);
+ if (!ProcessedFirstArg)
+ ProcessedFirstArg = true;
}
llvm::DIArray EltTypeArray =
More information about the llvm-commits
mailing list