[llvm-commits] [llvm-gcc-4.2] r109316 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h
Bob Wilson
bob.wilson at apple.com
Fri Jul 23 22:39:51 PDT 2010
This is causing buildbot failures. I'm going to revert it.
On Jul 23, 2010, at 6:18 PM, Devang Patel wrote:
> Author: dpatel
> Date: Fri Jul 23 20:18:19 2010
> New Revision: 109316
>
> URL: http://llvm.org/viewvc/llvm-project?rev=109316&view=rev
> Log:
> Simplify code and untangle filename/dirname confusion.
>
> DW_TAG_compile_unit uses two attributes DW_AT_name and DW_AT_comp_dir. Their expected values are:
>
> $ clang foo.c -g
> DW_AT_name - foo.c
> DW_AT_comp_dir - `pwd`
>
> $ clang one/two/foo.c -g
> DW_AT_name - one/two/foo.c
> DW_AT_comp_dir - `pwd`
>
> $ clang /tmp/one/foo.c -g
> DW_AT_name - /tmp/one/foo.c
> DW_AT_comp_dir - empty
>
>
> Modified:
> llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
> llvm-gcc-4.2/trunk/gcc/llvm-debug.h
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=109316&r1=109315&r2=109316&view=diff
> ==============================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Fri Jul 23 20:18:19 2010
> @@ -57,28 +57,16 @@
> #endif
>
>
> -/// DirectoryAndFile - Extract the directory and file name from a path. If no
> -/// directory is specified, then use the source working directory.
> +/// DirectoryAndFile - If Filename is absolute then directory name is empty.
> +/// Otherwise directory name is current working directory.
> static void DirectoryAndFile(const std::string &FullPath,
> std::string &Directory, std::string &FileName) {
> - // Look for the directory slash.
> - size_t Slash = FullPath.rfind('/');
> -
> - // If no slash
> - if (Slash == std::string::npos) {
> - // The entire path is the file name.
> + FileName = FullPath;
> +
> + if (FullPath[0] != '/')
> + Directory = std::string(get_src_pwd());
> + else
> Directory = "";
> - FileName = FullPath;
> - } else {
> - // Separate the directory from the file name.
> - Directory = FullPath.substr(0, Slash);
> - FileName = FullPath.substr(Slash + 1);
> - }
> -
> - // If no directory present then use source working directory.
> - if (Directory.empty() || Directory[0] != '/') {
> - Directory = std::string(get_src_pwd()) + "/" + Directory;
> - }
> }
>
> /// NodeSizeInBits - Returns the size in bits stored in a tree node regardless
> @@ -1394,10 +1382,13 @@
> }
>
> // Get source file information.
> - std::string Directory;
> - std::string FileName;
> - DirectoryAndFile(FullPath, Directory, FileName);
> -
> + llvm::StringRef Dir;
> + if (FullPath[0] != '/') {
> + if (CWD.empty())
> + CWD = std::string(get_src_pwd());
> + Dir = llvm::StringRef(CWD);
> + }
> +
> // Set up Language number.
> unsigned LangTag;
> const std::string LanguageName(lang_hooks.name);
> @@ -1432,8 +1423,8 @@
> unsigned ObjcRunTimeVer = 0;
> if (flag_objc_abi != 0 && flag_objc_abi != -1)
> ObjcRunTimeVer = flag_objc_abi;
> - return DebugFactory.CreateCompileUnit(LangTag, FileName.c_str(),
> - Directory.c_str(),
> + return DebugFactory.CreateCompileUnit(LangTag, FullPath,
> + Dir,
> version_string, isMain,
> optimize, Flags,
> ObjcRunTimeVer);
> @@ -1449,10 +1440,13 @@
> }
>
> // Get source file information.
> - std::string Directory;
> - std::string FileName;
> - DirectoryAndFile(FullPath, Directory, FileName);
> - return DebugFactory.CreateFile(FileName, Directory, TheCU);
> + llvm::StringRef Dir;
> + if (FullPath[0] != '/') {
> + if (CWD.empty())
> + CWD = std::string(get_src_pwd());
> + Dir = llvm::StringRef(CWD);
> + }
> + return DebugFactory.CreateFile(FullPath, Dir, TheCU);
> }
>
> /* LLVM LOCAL end (ENTIRE FILE!) */
>
> Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
> URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=109316&r1=109315&r2=109316&view=diff
> ==============================================================================
> --- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
> +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Fri Jul 23 20:18:19 2010
> @@ -63,6 +63,7 @@
> int PrevLineNo; // Previous location line# encountered.
> BasicBlock *PrevBB; // Last basic block encountered.
> DICompileUnit TheCU; // The compile unit.
> + std::string CWD; // Current working directory.
>
> // Current GCC lexical block (or enclosing FUNCTION_DECL).
> tree_node *CurrentGCCLexicalBlock;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list