Index: cmake/modules/AddLLVM.cmake =================================================================== --- cmake/modules/AddLLVM.cmake +++ cmake/modules/AddLLVM.cmake @@ -95,7 +95,7 @@ LINK_FLAGS " -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}") else() set_property(TARGET ${target_name} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}") + LINK_FLAGS " -Wl,--version-script,\"${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}\"") endif() else() set(native_export_file "${target_name}.def") @@ -1437,7 +1437,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT LLVM_LINKER_IS_GOLD) # $ORIGIN is not interpreted at link time by ld.bfd set_property(TARGET ${name} APPEND_STRING PROPERTY - LINK_FLAGS " -Wl,-rpath-link,${LLVM_LIBRARY_OUTPUT_INTDIR} ") + LINK_FLAGS " -Wl,-rpath-link,\"${LLVM_LIBRARY_OUTPUT_INTDIR}\" ") endif() else() return() Index: docs/GettingStartedVS.rst =================================================================== --- docs/GettingStartedVS.rst +++ docs/GettingStartedVS.rst @@ -54,9 +54,6 @@ `_. Version 2.7 and newer are known to work. You will need `GnuWin32 `_ tools, too. -Do not install the LLVM directory tree into a path containing spaces (e.g. -``C:\Documents and Settings\...``) as the configure step will fail. - Getting Started =============== Index: test/BugPoint/compile-custom.ll =================================================================== --- test/BugPoint/compile-custom.ll +++ test/BugPoint/compile-custom.ll @@ -1,4 +1,4 @@ -; RUN: bugpoint -load %llvmshlibdir/BugpointPasses%shlibext --compile-custom --compile-command="%python %s.py arg1 arg2" --output-prefix %t %s | FileCheck %s +; RUN: bugpoint -load %llvmshlibdir/BugpointPasses%shlibext --compile-custom --compile-command="%python %^s.py arg1 arg2" --output-prefix %t %s | FileCheck %s ; REQUIRES: loadable_module ; Test that arguments are correctly passed in --compile-command. The output Index: test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test =================================================================== --- test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test +++ test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test @@ -1,7 +1,7 @@ REQUIRES: shell RUN: cd %T RUN: cp %p/Inputs/split-dwarf-empty.dwo %T -RUN: echo "%p/Inputs/split-dwarf-empty.o 0xdeadbeef" > %t.input +RUN: echo "\"%^p/Inputs/split-dwarf-empty.o\" 0xdeadbeef" > %t.input RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \ RUN: --default-arch=i386 < %t.input | FileCheck %s Index: test/DebugInfo/llvm-symbolizer.test =================================================================== --- test/DebugInfo/llvm-symbolizer.test +++ test/DebugInfo/llvm-symbolizer.test @@ -1,44 +1,44 @@ -RUN: echo "%p/Inputs/dwarfdump-test.elf-x86-64 0x400559" > %t.input -RUN: echo "%p/Inputs/dwarfdump-test.elf-x86-64.debuglink 0x400559" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-test.elf-x86-64 0x400436" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-test.elf-x86-64 0x400528" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-test.elf-x86-64 0x400586" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-test2.elf-x86-64 0x4004e8" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-test2.elf-x86-64 0x4004f4" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-test4.elf-x86-64 0x62c" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x8dc" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-inl-test.elf-x86-64 0xa05" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-inl-test.elf-x86-64 0x987" >> %t.input -RUN: echo "%p/Inputs/dwarfdump-inl-test.high_pc.elf-x86-64 0x568" >> %t.input -RUN: echo "\"%p/Inputs/dwarfdump-test3.elf-x86-64 space\" 0x640" >> %t.input -RUN: echo "\"%p/Inputs/dwarfdump-test3.elf-x86-64 space\" 0x633" >> %t.input -RUN: echo "\"%p/Inputs/dwarfdump-test3.elf-x86-64 space\" 0x62d" >> %t.input -RUN: echo "%p/Inputs/macho-universal 0x1f84" >> %t.input -RUN: echo "%p/Inputs/macho-universal:i386 0x1f67" >> %t.input -RUN: echo "%p/Inputs/macho-universal:x86_64 0x100000f05" >> %t.input -RUN: echo "%p/Inputs/llvm-symbolizer-dwo-test 0x400514" >> %t.input -RUN: echo "%p/Inputs/fission-ranges.elf-x86_64 0x720" >> %t.input -RUN: echo "%p/Inputs/arange-overlap.elf-x86_64 0x714" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test.elf-x86-64\" 0x400559" > %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test.elf-x86-64.debuglink\" 0x400559" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test.elf-x86-64\" 0x400436" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test.elf-x86-64\" 0x400528" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test.elf-x86-64\" 0x400586" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test2.elf-x86-64\" 0x4004e8" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test2.elf-x86-64\" 0x4004f4" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test4.elf-x86-64\" 0x62c" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-inl-test.elf-x86-64\" 0x8dc" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-inl-test.elf-x86-64\" 0xa05" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-inl-test.elf-x86-64\" 0x987" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-inl-test.high_pc.elf-x86-64\" 0x568" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test3.elf-x86-64 space\" 0x640" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test3.elf-x86-64 space\" 0x633" >> %t.input +RUN: echo "\"%^p/Inputs/dwarfdump-test3.elf-x86-64 space\" 0x62d" >> %t.input +RUN: echo "\"%^p/Inputs/macho-universal\" 0x1f84" >> %t.input +RUN: echo "\"%^p/Inputs/macho-universal:i386\" 0x1f67" >> %t.input +RUN: echo "\"%^p/Inputs/macho-universal:x86_64\" 0x100000f05" >> %t.input +RUN: echo "\"%^p/Inputs/llvm-symbolizer-dwo-test\" 0x400514" >> %t.input +RUN: echo "\"%^p/Inputs/fission-ranges.elf-x86_64\" 0x720" >> %t.input +RUN: echo "\"%^p/Inputs/arange-overlap.elf-x86_64\" 0x714" >> %t.input RUN: cp %p/Inputs/split-dwarf-test.dwo %T -RUN: echo "%p/Inputs/split-dwarf-test 0x4005d4" >> %t.input -RUN: echo "%p/Inputs/split-dwarf-test 0x4005c4" >> %t.input -RUN: echo "%p/Inputs/cross-cu-inlining.x86_64-macho.o 0x17" >> %t.input +RUN: echo "\"%^p/Inputs/split-dwarf-test\" 0x4005d4" >> %t.input +RUN: echo "\"%^p/Inputs/split-dwarf-test\" 0x4005c4" >> %t.input +RUN: echo "\"%^p/Inputs/cross-cu-inlining.x86_64-macho.o\" 0x17" >> %t.input RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \ RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=CHECK --check-prefix=SPLIT --check-prefix=DWO %s Ensure we get the same results in the absence of gmlt-like data in the executable but the presence of a .dwo file -RUN: echo "%p/Inputs/split-dwarf-test-nogmlt 0x4005d4" >> %t.input -RUN: echo "%p/Inputs/split-dwarf-test-nogmlt 0x4005c4" >> %t.input +RUN: echo "\"%^p/Inputs/split-dwarf-test-nogmlt\" 0x4005d4" >> %t.input +RUN: echo "\"%^p/Inputs/split-dwarf-test-nogmlt\" 0x4005c4" >> %t.input RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \ RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=SPLIT --check-prefix=DWO %s Ensure we get gmlt like results in the absence of a .dwo file but the presence of gmlt-like data in the executable RUN: rm %T/split-dwarf-test.dwo -RUN: echo "%p/Inputs/split-dwarf-test 0x4005d4" >> %t.input -RUN: echo "%p/Inputs/split-dwarf-test 0x4005c4" >> %t.input +RUN: echo "\"%^p/Inputs/split-dwarf-test\" 0x4005d4" >> %t.input +RUN: echo "\"%^p/Inputs/split-dwarf-test\" 0x4005c4" >> %t.input RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \ RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=SPLIT --check-prefix=NODWO %s @@ -138,7 +138,7 @@ MISSING-FILE: LLVMSymbolizer: error reading file: {{[Nn]}}o such file or directory -RUN: echo "%p/Inputs/macho-universal 0x1f84" > %t.input3 +RUN: echo "\"%^p/Inputs/macho-universal\" 0x1f84" > %t.input3 RUN: llvm-symbolizer < %t.input3 | FileCheck %s --check-prefix=UNKNOWN-ARCH UNKNOWN-ARCH-NOT: main @@ -171,7 +171,7 @@ STRIPPED: global_func -RUN: echo "%p/Inputs/dwarfdump-test4.elf-x86-64 0x62c" > %t.input7 +RUN: echo "\"%^p/Inputs/dwarfdump-test4.elf-x86-64\" 0x62c" > %t.input7 RUN: llvm-symbolizer --functions=short --demangle=false < %t.input7 \ RUN: | FileCheck %s --check-prefix=SHORT_FUNCTION_NAME Index: test/LibDriver/libpath.test =================================================================== --- test/LibDriver/libpath.test +++ test/LibDriver/libpath.test @@ -2,7 +2,7 @@ RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %T/a/foo.obj %S/Inputs/a.s RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %T/b/foo.obj %S/Inputs/b.s -RUN: env "LIB=%T/a;%T/b" llvm-lib /out:%t1.lib foo.obj +RUN: env "LIB=%^T/a;%^T/b" llvm-lib /out:%t1.lib foo.obj RUN: llvm-nm %t1.lib | FileCheck --check-prefix=A %s RUN: llvm-lib /out:%t2.lib /libpath:%T/a /libpath:%T/b foo.obj Index: test/Object/mri-addmod.test =================================================================== --- test/Object/mri-addmod.test +++ test/Object/mri-addmod.test @@ -1,5 +1,5 @@ ; RUN: echo create %t.a > %t.mri -; RUN: echo "addmod \"%p/Inputs/trivial-object-test.elf-x86-64\" " >> %t.mri +; RUN: echo "addmod \"%^p/Inputs/trivial-object-test.elf-x86-64\" " >> %t.mri ; RUN: echo save >> %t.mri ; RUN: echo end >> %t.mri Index: test/Object/nm-archive.test =================================================================== --- test/Object/nm-archive.test +++ test/Object/nm-archive.test @@ -29,7 +29,7 @@ RUN: llvm-nm %t2 | FileCheck %s -check-prefix BITCODE RUN: rm -f %t2 -RUN: echo /out:%t2 %t1 > %t.rsp +RUN: echo "\"/out:%^t2\" \"%^t1\"" > %t.rsp RUN: llvm-lib @%t.rsp RUN: llvm-nm %t2 | FileCheck %s -check-prefix BITCODE Index: test/Other/ResponseFile.ll =================================================================== --- test/Other/ResponseFile.ll +++ test/Other/ResponseFile.ll @@ -3,8 +3,8 @@ ; file for us. Tokenization with quotes is tested in unittests. ; On Windows, paths contain \ characters, which are escape characters in ; GNU-style response files. So replace \ with \\ to make the tests work there. -; RUN: echo %s | sed -e 's:\\:\\\\:g' > %t.list1 -; RUN: echo "-time-passes @%t.list1" | sed -e 's:\\:\\\\:g' > %t.list2 +; RUN: echo "\"%^s\"" | sed -e 's:\\:\\\\:g' > %t.list1 +; RUN: echo "-time-passes \"@%^t.list1\"" | sed -e 's:\\:\\\\:g' > %t.list2 ; RUN: llvm-as @%t.list2 -o %t.bc ; RUN: llvm-nm %t.bc 2>&1 | FileCheck %s Index: test/ThinLTO/X86/prefix_replace.ll =================================================================== --- test/ThinLTO/X86/prefix_replace.ll +++ test/ThinLTO/X86/prefix_replace.ll @@ -7,7 +7,7 @@ ; RUN: rm -f %T/newpath/prefix_replace.o.thinlto.bc ; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %T/oldpath/prefix_replace.o -; RUN: llvm-lto -thinlto-action=distributedindexes -thinlto-prefix-replace="%T/oldpath/;%T/newpath/" -thinlto-index %t.index.bc %T/oldpath/prefix_replace.o +; RUN: llvm-lto -thinlto-action=distributedindexes -thinlto-prefix-replace="%^T/oldpath/;%^T/newpath/" -thinlto-index %t.index.bc %T/oldpath/prefix_replace.o ; RUN: ls %T/newpath/prefix_replace.o.thinlto.bc Index: test/Transforms/GCOVProfiling/function-numbering.ll =================================================================== --- test/Transforms/GCOVProfiling/function-numbering.ll +++ test/Transforms/GCOVProfiling/function-numbering.ll @@ -2,7 +2,7 @@ ; functions aren't emitted. ; Inject metadata to set the .gcno file location -; RUN: echo '!14 = !{!"%/T/function-numbering.ll", !0}' > %t1 +; RUN: echo '!14 = !{!"%^/T/function-numbering.ll", !0}' > %t1 ; RUN: cat %s %t1 > %t2 ; RUN: opt -insert-gcov-profiling -S < %t2 | FileCheck --check-prefix GCDA %s Index: test/Transforms/GCOVProfiling/global-ctor.ll =================================================================== --- test/Transforms/GCOVProfiling/global-ctor.ll +++ test/Transforms/GCOVProfiling/global-ctor.ll @@ -1,4 +1,4 @@ -; RUN: echo '!16 = !{!"%/T/global-ctor.ll", !0}' > %t1 +; RUN: echo '!16 = !{!"%^/T/global-ctor.ll", !0}' > %t1 ; RUN: cat %s %t1 > %t2 ; RUN: opt -insert-gcov-profiling -disable-output < %t2 ; RUN: not grep '_GLOBAL__sub_I_global-ctor' %T/global-ctor.gcno Index: test/Transforms/GCOVProfiling/linezero.ll =================================================================== --- test/Transforms/GCOVProfiling/linezero.ll +++ test/Transforms/GCOVProfiling/linezero.ll @@ -1,7 +1,7 @@ -; RUN: sed -e 's|PATTERN|%/T|g' %s | opt -insert-gcov-profiling -disable-output +; RUN: sed -e 's|PATTERN|%^/T|g' %s | opt -insert-gcov-profiling -disable-output ; RUN: rm %T/linezero.gcno -; RUN: sed -e 's|PATTERN|%/T|g' %s | opt -passes=insert-gcov-profiling -disable-output +; RUN: sed -e 's|PATTERN|%^/T|g' %s | opt -passes=insert-gcov-profiling -disable-output ; RUN: rm %T/linezero.gcno ; This is a crash test. Index: test/Transforms/GCOVProfiling/linkagename.ll =================================================================== --- test/Transforms/GCOVProfiling/linkagename.ll +++ test/Transforms/GCOVProfiling/linkagename.ll @@ -1,4 +1,4 @@ -; RUN: echo '!9 = !{!"%/T/linkagename.ll", !0}' > %t1 +; RUN: echo '!9 = !{!"%^/T/linkagename.ll", !0}' > %t1 ; RUN: cat %s %t1 > %t2 ; RUN: opt -insert-gcov-profiling -disable-output < %t2 ; RUN: grep _Z3foov %T/linkagename.gcno Index: test/Transforms/GCOVProfiling/return-block.ll =================================================================== --- test/Transforms/GCOVProfiling/return-block.ll +++ test/Transforms/GCOVProfiling/return-block.ll @@ -1,5 +1,5 @@ ; Inject metadata to set the .gcno file location -; RUN: echo '!19 = !{!"%/T/return-block.ll", !0}' > %t1 +; RUN: echo '!19 = !{!"%^/T/return-block.ll", !0}' > %t1 ; RUN: cat %s %t1 > %t2 ; By default, the return block is last. Index: test/Transforms/GCOVProfiling/three-element-mdnode.ll =================================================================== --- test/Transforms/GCOVProfiling/three-element-mdnode.ll +++ test/Transforms/GCOVProfiling/three-element-mdnode.ll @@ -1,4 +1,4 @@ -; RUN: echo '!10 = !{!"%/T/aaa.gcno", !"%/T/bbb.gcda", !0}' > %t1 +; RUN: echo '!10 = !{!"%^/T/aaa.gcno", !"%/T/bbb.gcda", !0}' > %t1 ; RUN: cat %s %t1 > %t2 ; RUN: opt -insert-gcov-profiling -S -o %t3 < %t2 ; RUN: grep _Z3foov %T/aaa.gcno Index: test/Transforms/GCOVProfiling/version.ll =================================================================== --- test/Transforms/GCOVProfiling/version.ll +++ test/Transforms/GCOVProfiling/version.ll @@ -1,4 +1,4 @@ -; RUN: echo '!9 = !{!"%/T/version.ll", !0}' > %t1 +; RUN: echo '!9 = !{!"%^/T/version.ll", !0}' > %t1 ; RUN: cat %s %t1 > %t2 ; RUN: opt -insert-gcov-profiling -disable-output < %t2 ; RUN: head -c8 %T/version.gcno | grep '^oncg.204' Index: test/lit.cfg =================================================================== --- test/lit.cfg +++ test/lit.cfg @@ -209,13 +209,13 @@ config.substitutions.append( ('%llc_dwarf', llc_dwarf) ) # Add site-specific substitutions. -config.substitutions.append( ('%gold', config.gold_executable) ) -config.substitutions.append( ('%go', config.go_executable) ) -config.substitutions.append( ('%llvmshlibdir', config.llvm_shlib_dir) ) -config.substitutions.append( ('%shlibext', config.llvm_shlib_ext) ) -config.substitutions.append( ('%exeext', config.llvm_exe_ext) ) -config.substitutions.append( ('%python', config.python_executable) ) -config.substitutions.append( ('%host_cc', config.host_cc) ) +config.substitutions.append( ('%gold', lit.util.escapeSpaces(config.gold_executable)) ) +config.substitutions.append( ('%go', lit.util.escapeSpaces(config.go_executable)) ) +config.substitutions.append( ('%llvmshlibdir', lit.util.escapeSpaces(config.llvm_shlib_dir)) ) +config.substitutions.append( ('%shlibext', lit.util.escapeSpaces(config.llvm_shlib_ext)) ) +config.substitutions.append( ('%exeext', lit.util.escapeSpaces(config.llvm_exe_ext)) ) +config.substitutions.append( ('%python', lit.util.escapeSpaces(config.python_executable)) ) +config.substitutions.append( ('%host_cc', lit.util.escapeSpaces(config.host_cc)) ) # Provide the path to asan runtime lib if available. On darwin, this lib needs # to be loaded via DYLD_INSERT_LIBRARIES before libLTO.dylib in case the files @@ -331,7 +331,7 @@ # Warn, but still provide a substitution. lit_config.note('Did not find ' + tool_name + ' in ' + llvm_tools_dir) tool_path = llvm_tools_dir + '/' + tool_name - config.substitutions.append((pattern, tool_pipe + tool_path)) + config.substitutions.append((pattern, tool_pipe + lit.util.escapeSpaces(tool_path))) # For tools that are optional depending on the config, we won't warn # if they're missing. @@ -346,7 +346,7 @@ if not tool_path: # Provide a substitution anyway, for the sake of consistent errors. tool_path = llvm_tools_dir + '/' + tool_name - config.substitutions.append((pattern, tool_pipe + tool_path)) + config.substitutions.append((pattern, tool_pipe + lit.util.escapeSpaces(tool_path))) ### Targets Index: test/tools/llvm-profdata/input-dir.test =================================================================== --- test/tools/llvm-profdata/input-dir.test +++ test/tools/llvm-profdata/input-dir.test @@ -1,7 +1,7 @@ # Create an input file. RUN: echo "#" > %t.input -RUN: echo "%t.dir1" >> %t.input -RUN: echo "2,%t.dir2" >> %t.input +RUN: echo "%^t.dir1" >> %t.input +RUN: echo "2,%^t.dir2" >> %t.input RUN: mkdir -p %t.dir1 RUN: mkdir -p %t.dir2/subdir Index: test/tools/llvm-profdata/input-filenames.test =================================================================== --- test/tools/llvm-profdata/input-filenames.test +++ test/tools/llvm-profdata/input-filenames.test @@ -1,9 +1,9 @@ # Create an input file. RUN: echo '# comment 1' > %t.input RUN: echo ' # comment 2' >> %t.input -RUN: echo " %t.bar" >> %t.input -RUN: echo " %t.baz" >> %t.input -RUN: echo "2,%t.weighted" >> %t.input +RUN: echo " %^t.bar" >> %t.input +RUN: echo " %^t.baz" >> %t.input +RUN: echo "2,%^t.weighted" >> %t.input RUN: echo ' ' > %t.weighted RUN: echo ' ' > %t.foo Index: test/tools/llvm-symbolizer/coff-dwarf.test =================================================================== --- test/tools/llvm-symbolizer/coff-dwarf.test +++ test/tools/llvm-symbolizer/coff-dwarf.test @@ -1,5 +1,5 @@ RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ -RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-dwarf.exe" \ +RUN: | llvm-symbolizer --inlining --relative-address -obj="%^p/Inputs/coff-dwarf.exe" \ RUN: | FileCheck %s This test relies on UnDecorateSymbolName, which is Windows-only. Index: test/tools/llvm-symbolizer/coff-exports.test =================================================================== --- test/tools/llvm-symbolizer/coff-exports.test +++ test/tools/llvm-symbolizer/coff-exports.test @@ -1,5 +1,5 @@ RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \ -RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-exports.exe" \ +RUN: | llvm-symbolizer --inlining --relative-address -obj="%^p/Inputs/coff-exports.exe" \ RUN: | FileCheck %s This test relies on UnDecorateSymbolName, which is Win32-only. Index: test/tools/llvm-symbolizer/dsym.test =================================================================== --- test/tools/llvm-symbolizer/dsym.test +++ test/tools/llvm-symbolizer/dsym.test @@ -1,5 +1,5 @@ -RUN: echo "%p/Inputs/dsym-test-exe 0x0000000100000f90" > %t.input -RUN: echo "%p/Inputs/dsym-test-exe-second 0x0000000100000f90" >> %t.input +RUN: echo "\"%^p/Inputs/dsym-test-exe\" 0x0000000100000f90" > %t.input +RUN: echo "\"%^p/Inputs/dsym-test-exe-second\" 0x0000000100000f90" >> %t.input RUN: llvm-symbolizer < %t.input | FileCheck %s --check-prefix=CHECK-NOHINT RUN: llvm-symbolizer -dsym-hint=%p/Inputs/dsym-test-exe-differentname.dSYM < %t.input | FileCheck %s --check-prefix=CHECK-HINT Index: test/tools/sanstats/elf.test =================================================================== --- test/tools/sanstats/elf.test +++ test/tools/sanstats/elf.test @@ -3,7 +3,7 @@ # RUN: printf "\x04" > %t.stats -# RUN: printf "%%s" "%t1.o" >> %t.stats +# RUN: printf "%%s" %t1.o >> %t.stats # RUN: printf "\x00" >> %t.stats # RUN: printf "\x01\x00\x00\x00\x01\x00\x00\x00" >> %t.stats # RUN: printf "\x11\x00\x00\x00\x02\x00\x00\x20" >> %t.stats @@ -13,7 +13,7 @@ # RUN: printf "\x21\x00\x00\x00\x06\x00\x00\xa0" >> %t.stats # RUN: printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> %t.stats -# RUN: printf "%%s" "%t2.o" >> %t.stats +# RUN: printf "%%s" %t2.o >> %t.stats # RUN: printf "\x00" >> %t.stats # RUN: printf "\x21\x00\x00\x00\x07\x00\x00\x00" >> %t.stats # RUN: printf "\x11\x00\x00\x00\x08\x00\x00\x20" >> %t.stats Index: utils/GetRepositoryPath =================================================================== --- utils/GetRepositoryPath +++ utils/GetRepositoryPath @@ -9,11 +9,11 @@ exit 1 } -if [ $# != 1 ] || [ ! -d $1 ]; then +if [ $# != 1 ] || [ ! -d "$1" ]; then usage; fi -cd $1 +cd "$1" if [ -d .svn ]; then svn info | grep '^URL:' | cut -d: -f2- elif [ -f .git/svn/.metadata ]; then Index: utils/GetSourceVersion =================================================================== --- utils/GetSourceVersion +++ utils/GetSourceVersion @@ -9,11 +9,11 @@ exit 1 } -if [ $# != 1 ] || [ ! -d $1 ]; then +if [ $# != 1 ] || [ ! -d "$1" ]; then usage; fi -cd $1 +cd "$1" if [ -d .svn ]; then svnversion | sed -e "s#\([0-9]*\)[A-Z]*#\1#" elif [ -f .git/svn/.metadata ]; then Index: utils/lit/lit/ShUtil.py =================================================================== --- utils/lit/lit/ShUtil.py +++ utils/lit/lit/ShUtil.py @@ -2,6 +2,7 @@ import itertools import lit.util +from lit.util import escapeChar from lit.ShCommands import Command, Pipeline, Seq class ShLexer: @@ -31,12 +32,14 @@ def lex_arg_fast(self, c): # Get the leading whitespace free section. chunk = self.data[self.pos - 1:].split(None, 1)[0] - + + escape_char = escapeChar(self.win32Escapes) + # If it has special characters, the fast path failed. if ('|' in chunk or '&' in chunk or '<' in chunk or '>' in chunk or "'" in chunk or '"' in chunk or - ';' in chunk or '\\' in chunk): + ';' in chunk or escape_char in chunk): return None self.pos = self.pos - 1 + len(chunk) @@ -71,8 +74,8 @@ elif c == "'": self.eat() str += self.lex_arg_quoted("'") - elif not self.win32Escapes and c == '\\': - # Outside of a string, '\\' escapes everything. + elif c == escapeChar(self.win32Escapes): + # Outside of a string, '\\' (or '^' on windows) escapes everything. self.eat() if self.pos == self.end: lit.util.warning( Index: utils/lit/lit/TestRunner.py =================================================================== --- utils/lit/lit/TestRunner.py +++ utils/lit/lit/TestRunner.py @@ -8,7 +8,7 @@ import lit.ShUtil as ShUtil import lit.Test as Test import lit.util -from lit.util import to_bytes, to_string +from lit.util import to_bytes, to_string, escapeSpaces from lit.BooleanExpression import BooleanExpression class InternalShellError(Exception): @@ -673,53 +673,100 @@ return tmpDir, tmpBase def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False): - sourcepath = test.getSourcePath() - sourcedir = os.path.dirname(sourcepath) + sourcePath = test.getSourcePath() + sourceDir = os.path.dirname(sourcePath) + + normSourcePath = sourcePath.replace('\\', '/') + normSourceDir = sourceDir.replace('\\', '/') + normTmpDir = tmpDir.replace('\\', '/') + normTmpBase = tmpBase.replace('\\', '/') # Normalize slashes, if requested. if normalize_slashes: - sourcepath = sourcepath.replace('\\', '/') - sourcedir = sourcedir.replace('\\', '/') - tmpDir = tmpDir.replace('\\', '/') - tmpBase = tmpBase.replace('\\', '/') + sourcePath = normSourcePath + sourceDir = normSourceDir + tmpDir = normTmpDir + tmpBase = normTmpBase + + # handle spaces in paths + escapedSourcePath = escapeSpaces(sourcePath) + escapedSourceDir = escapeSpaces(sourceDir) + escapedTmpDir = escapeSpaces(tmpDir) + escapedTmpBase = escapeSpaces(tmpBase) # We use #_MARKER_# to hide %% while we do the other substitutions. substitutions = [] substitutions.extend([('%%', '#_MARKER_#')]) substitutions.extend(test.config.substitutions) - substitutions.extend([('%s', sourcepath), - ('%S', sourcedir), - ('%p', sourcedir), + substitutions.extend([('%s', escapedSourcePath), + ('%S', escapedSourceDir), + ('%p', escapedSourceDir), ('%{pathsep}', os.pathsep), - ('%t', tmpBase + '.tmp'), - ('%T', tmpDir), + ('%t', escapedTmpBase + '.tmp'), + ('%T', escapedTmpDir), ('#_MARKER_#', '%')]) + # "%^[STpst]" should not have spaces escaped. + substitutions.extend([ + ('%\^s', sourcePath), + ('%\^S', sourceDir), + ('%\^p', sourceDir), + ('%\^t', tmpBase + '.tmp'), + ('%\^T', tmpDir), + ]) + # "%/[STpst]" should be normalized. substitutions.extend([ - ('%/s', sourcepath.replace('\\', '/')), - ('%/S', sourcedir.replace('\\', '/')), - ('%/p', sourcedir.replace('\\', '/')), - ('%/t', tmpBase.replace('\\', '/') + '.tmp'), - ('%/T', tmpDir.replace('\\', '/')), + ('%/s', escapeSpaces(normSourcePath)), + ('%/S', escapeSpaces(normSourceDir)), + ('%/p', escapeSpaces(normSourceDir)), + ('%/t', escapeSpaces(normTmpBase + '.tmp')), + ('%/T', escapeSpaces(normTmpDir)), ]) - # "%:[STpst]" are paths without colons. + # "%^/[STpst]" should be normalized and unescaped. + substitutions.extend([ + ('%\^/s', normSourcePath), + ('%\^/S', normSourceDir), + ('%\^/p', normSourceDir), + ('%\^/t', normTmpBase + '.tmp'), + ('%\^/T', normTmpDir), + ]) + + # "%:[STpst]" are escaped paths without colons. + if kIsWindows: + substitutions.extend([ + ('%:s', re.sub(r'^(.):', r'\1', escapedSourcePath)), + ('%:S', re.sub(r'^(.):', r'\1', escapedSourceDir)), + ('%:p', re.sub(r'^(.):', r'\1', escapedSourceDir)), + ('%:t', re.sub(r'^(.):', r'\1', escapedTmpBase) + '.tmp'), + ('%:T', re.sub(r'^(.):', r'\1', escapedTmpDir)), + ]) + else: + substitutions.extend([ + ('%:s', escapedSourcePath), + ('%:S', escapedSourceDir), + ('%:p', escapedSourceDir), + ('%:t', escapedTmpBase + '.tmp'), + ('%:T', escapedTmpDir), + ]) + + # "%^:[STpst]" are unescaped paths without colons. if kIsWindows: substitutions.extend([ - ('%:s', re.sub(r'^(.):', r'\1', sourcepath)), - ('%:S', re.sub(r'^(.):', r'\1', sourcedir)), - ('%:p', re.sub(r'^(.):', r'\1', sourcedir)), - ('%:t', re.sub(r'^(.):', r'\1', tmpBase) + '.tmp'), - ('%:T', re.sub(r'^(.):', r'\1', tmpDir)), + ('%\^:s', re.sub(r'^(.):', r'\1', sourcePath)), + ('%\^:S', re.sub(r'^(.):', r'\1', sourceDir)), + ('%\^:p', re.sub(r'^(.):', r'\1', sourceDir)), + ('%\^:t', re.sub(r'^(.):', r'\1', tmpBase) + '.tmp'), + ('%\^:T', re.sub(r'^(.):', r'\1', tmpDir)), ]) else: substitutions.extend([ - ('%:s', sourcepath), - ('%:S', sourcedir), - ('%:p', sourcedir), - ('%:t', tmpBase + '.tmp'), - ('%:T', tmpDir), + ('%\^:s', sourcePath), + ('%\^:S', sourceDir), + ('%\^:p', sourceDir), + ('%\^:t', tmpBase + '.tmp'), + ('%\^:T', tmpDir), ]) return substitutions Index: utils/lit/lit/util.py =================================================================== --- utils/lit/lit/util.py +++ utils/lit/lit/util.py @@ -27,6 +27,25 @@ except UnicodeError: return str(bytes) +def escapeChar (win32Escapes): + if win32Escapes: + return '^' + else: + return '\\' + +def escapeSpaces (s): + """ + Escapes spaces in strings. Igores whitespace at the start and end of the + string. + """ + first = len(s) - len(s.lstrip()) + last = len(s.rstrip()) + + escape = escapeChar('win32' == sys.platform) + escapedStr = s[first:last].replace(' ', escape + ' ') + + return s[:first] + escapedStr + s[last:] + def detectCPUs(): """ Detects the number of CPUs on a system. Cribbed from pp. Index: utils/lit/tests/lit.cfg =================================================================== --- utils/lit/tests/lit.cfg +++ utils/lit/tests/lit.cfg @@ -27,12 +27,14 @@ src_root = os.path.join(config.test_source_root, '..') config.environment['PYTHONPATH'] = src_root -config.substitutions.append(('%{src_root}', src_root)) -config.substitutions.append(('%{inputs}', os.path.join( - src_root, 'tests', 'Inputs'))) + +# escaped versions +config.substitutions.append(('%{src_root}', lit.util.escapeSpaces(src_root))) +config.substitutions.append(('%{inputs}', lit.util.escapeSpaces(os.path.join( + src_root, 'tests', 'Inputs')))) config.substitutions.append(('%{lit}', "%%{python} %s" % ( - os.path.join(src_root, 'lit.py'),))) -config.substitutions.append(('%{python}', sys.executable)) + lit.util.escapeSpaces(os.path.join(src_root, 'lit.py')),))) +config.substitutions.append(('%{python}', lit.util.escapeSpaces(sys.executable))) # Enable coverage.py reporting, assuming the coverage module has been installed # and sitecustomize.py in the virtualenv has been modified appropriately. Index: utils/lit/tests/sp aces/check-for-spaces.py =================================================================== --- /dev/null +++ utils/lit/tests/sp aces/check-for-spaces.py @@ -0,0 +1,12 @@ +# check that spaces in paths are escaped properly +# RUN: python %s %s | FileCheck %s --check-prefix ESCAPED +# ESCAPED: sp aces + +# check that ^ substitutions do not escape spaces +# RUN: python %s %^s | FileCheck %s --check-prefix SPLIT +# SPLIT-NOT: sp aces + +import sys +print sys.argv [-1] + + Index: utils/lit/tests/sp aces/spaces-in-paths.py =================================================================== --- /dev/null +++ utils/lit/tests/sp aces/spaces-in-paths.py @@ -0,0 +1,3 @@ +# check that lit can deal with a path continaing spaces + +# RUN: %{lit} -j 1 -v check-for-spaces.py Index: utils/lit/tests/unit/ShUtil.py =================================================================== --- utils/lit/tests/unit/ShUtil.py +++ utils/lit/tests/unit/ShUtil.py @@ -37,6 +37,8 @@ ["", ""]) self.assertEqual(self.lex(""" a\\ b """, win32Escapes = True), ['a\\', 'b']) + self.assertEqual(self.lex(""" a^ b """, win32Escapes = True), + ['a b']) class TestShParse(unittest.TestCase): def parse(self, str):