llvm.org GIT mirror llvm / b9c767c
Support/PathV1: Deprecate get{Basename,Dirname,Suffix}. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122141 91177308-0d34-0410-b5e6-96231b3b80d8 Michael J. Spencer 9 years ago
7 changed file(s) with 17 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
271271 /// this function to return "foo".
272272 /// @returns StringRef containing the basename of the path
273273 /// @brief Get the base name of the path
274 StringRef getBasename() const;
274 LLVM_ATTRIBUTE_DEPRECATED(StringRef getBasename() const,
275 LLVMV_PATH_DEPRECATED_MSG);
275276
276277 /// This function strips off the suffix of the path beginning with the
277278 /// path separator ('/' on Unix, '\' on Windows) and returns the result.
278 StringRef getDirname() const;
279 LLVM_ATTRIBUTE_DEPRECATED(StringRef getDirname() const,
280 LLVMV_PATH_DEPRECATED_MSG);
279281
280282 /// This function strips off the path and basename(up to and
281283 /// including the last dot) of the file or directory name and
283285 /// this function to return "bar".
284286 /// @returns StringRef containing the suffix of the path
285287 /// @brief Get the suffix of the path
286 StringRef getSuffix() const;
288 LLVM_ATTRIBUTE_DEPRECATED(StringRef getSuffix() const,
289 LLVMV_PATH_DEPRECATED_MSG);
287290
288291 /// Obtain a 'C' string for the path name.
289292 /// @returns a 'C' string containing the path name.
3131 namespace llvmc {
3232
3333 const std::string* LanguageMap::GetLanguage(const sys::Path& File) const {
34 StringRef suf = File.getSuffix();
34 StringRef suf = sys::path::extension(File.str());
3535 LanguageMap::const_iterator Lang =
3636 this->find(suf.empty() ? "*empty*" : suf);
3737 if (Lang == this->end()) {
4242 return 0;
4343 }
4444 else if (SaveTemps == SaveTempsEnum::Obj && !OutputFilename.empty()) {
45 tempDir = OutputFilename;
46 tempDir = tempDir.getDirname();
45 tempDir = sys::path::parent_path(OutputFilename);
4746 }
4847 else {
4948 // SaveTemps == Cwd --> use current dir (leave tempDir empty).
6060 Out.appendSuffix(OutputSuffix);
6161 }
6262 else {
63 Out.set(In.getBasename());
63 Out.set(sys::path::stem(In.str()));
6464 Out.appendSuffix(OutputSuffix);
6565 }
6666 }
6868 if (IsJoin())
6969 Out = MakeTempFile(TempDir, "tmp", OutputSuffix);
7070 else
71 Out = MakeTempFile(TempDir, In.getBasename(), OutputSuffix);
71 Out = MakeTempFile(TempDir, sys::path::stem(In.str()), OutputSuffix);
7272 }
7373 return Out;
7474 }
13001300
13011301 // If the source library's module id is in the dependent library list of the
13021302 // destination library, remove it since that module is now linked in.
1303 sys::Path modId;
1304 modId.set(Src->getModuleIdentifier());
1305 if (!modId.isEmpty())
1306 Dest->removeLibrary(modId.getBasename());
1303 const std::string &modId = Src->getModuleIdentifier();
1304 if (!modId.empty())
1305 Dest->removeLibrary(sys::path::stem(modId));
13071306
13081307 return false;
13091308 }
525525 initializeTarget(Registry);
526526
527527 // Initial global variable above for convenience printing of program name.
528 progname = sys::Path(argv[0]).getBasename();
528 progname = sys::path::stem(argv[0]);
529529
530530 // Parse the command line options
531531 cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
537537 OutputFilename = "a.exe";
538538
539539 // If there is no suffix add an "exe" one.
540 sys::Path ExeFile( OutputFilename );
541 if (ExeFile.getSuffix() == "") {
542 ExeFile.appendSuffix("exe");
543 OutputFilename = ExeFile.str();
544 }
540 if (sys::path::extension(OutputFilename).empty())
541 OutputFilename.append(".exe");
545542 }
546543 #endif
547544
522522 errs().indent(ToolName.size()) << ": DLL Name : " << DLLName << '\n';
523523 }
524524
525 if (NoUser32 && sys::Path(DLLName).getBasename() == "user32") {
525 if (NoUser32 && sys::path::stem(DLLName) == "user32") {
526526 // Program is loading user32.dll, in the applications we are testing,
527527 // this only happens if an assert has fired. By now the message has
528528 // already been printed, so simply close the program.