[cfe-commits] r168002 - /cfe/trunk/utils/ClangDataFormat.py

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Nov 14 15:52:12 PST 2012


Author: akirtzidis
Date: Wed Nov 14 17:52:11 2012
New Revision: 168002

URL: http://llvm.org/viewvc/llvm-project?rev=168002&view=rev
Log:
[utils/ClangDataFormat.py] In the summary of SourceLocation, include whether it is
local or loaded.

Modified:
    cfe/trunk/utils/ClangDataFormat.py

Modified: cfe/trunk/utils/ClangDataFormat.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ClangDataFormat.py?rev=168002&r1=168001&r2=168002&view=diff
==============================================================================
--- cfe/trunk/utils/ClangDataFormat.py (original)
+++ cfe/trunk/utils/ClangDataFormat.py Wed Nov 14 17:52:11 2012
@@ -16,7 +16,7 @@
 you'll get:
 
 (lldb) p Tok.Loc
-(clang::SourceLocation) $4 = "/usr/include/i386/_types.h:37:1" (offset: 123582, file)
+(clang::SourceLocation) $4 = "/usr/include/i386/_types.h:37:1" (offset: 123582, file, local)
 """
 
 import lldb
@@ -37,6 +37,9 @@
 	def isMacro(self):
 		return getValueFromExpression(self.srcloc, ".isMacroID()").GetValueAsUnsigned()
 
+	def isLocal(self, srcmgr_path):
+		return lldb.frame.EvaluateExpression("(%s).isLocalSourceLocation(%s)" % (srcmgr_path, getExpressionPath(self.srcloc))).GetValueAsUnsigned()
+
 	def getPrint(self, srcmgr_path):
 		print_str = getValueFromExpression(self.srcloc, ".printToString(%s)" % srcmgr_path)
 		return print_str.GetSummary()
@@ -45,7 +48,7 @@
 		desc = "(offset: %d, %s)" % (self.offset(), "macro" if self.isMacro() else "file")
 		srcmgr_path = findObjectExpressionPath("clang::SourceManager", lldb.frame)
 		if srcmgr_path:
-			desc = self.getPrint(srcmgr_path) + " " + desc
+			desc = "%s (offset: %d, %s, %s)" % (self.getPrint(srcmgr_path), self.offset(), "macro" if self.isMacro() else "file", "local" if self.isLocal(srcmgr_path) else "loaded")
 		return desc
 
 # Key is a (function address, type name) tuple, value is the expression path for





More information about the cfe-commits mailing list