Support/Path: Deprecate PathV1::isAbsolute.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Fri, 17 Dec 2010 21:21:31 +0000 (21:21 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Fri, 17 Dec 2010 21:21:31 +0000 (21:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122086 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/SmallString.h
include/llvm/Support/Compiler.h
include/llvm/Support/PathV1.h
lib/CompilerDriver/Action.cpp

index 4388a85edbe60b9cb34ebb1fd1dc88ba16f7c2c9..da264164821f2a9bcf209e4641dae75a6e8aa8da 100644 (file)
@@ -27,6 +27,9 @@ public:
   // Default ctor - Initialize to empty.
   SmallString() {}
 
+  // Initialize from a StringRef.
+  SmallString(StringRef S) : SmallVector<char, InternalLen>(S.begin(), S.end()) {}
+
   // Initialize with a range.
   template<typename ItTy>
   SmallString(ItTy S, ItTy E) : SmallVector<char, InternalLen>(S, E) {}
index 6ac7f9c0b0426e98af8979a3d610899414c79dfa..67f0fd7e0dc6747989dece751db2fc74fcbf0a70 100644 (file)
 #ifndef LLVM_SUPPORT_COMPILER_H
 #define LLVM_SUPPORT_COMPILER_H
 
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
 /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked
 /// into a shared library, then the class should be private to the library and
 /// not accessible from outside it.  Can also be used to mark variables and
 #define LLVM_ATTRIBUTE_NORETURN
 #endif
 
+// LLVM_ATTRIBUTE_DEPRECATED(decl, "message")
+#if __has_feature(attribute_deprecated_with_message)
+# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
+  decl __attribute__((deprecated(message)))
+#elif defined(__GNUC__)
+# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
+  decl __attribute__((deprecated))
+#elif defined(_MSC_VER)
+# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
+  __declspec(deprecated(message)) decl
+#else
+# define LLVM_ATTRIBUTE_DEPRECATED(decl, message) \
+  decl
+#endif
+
 #endif
index 74215cb0c1e989f601734c5385f520dd11fa5ef5..5c0bdeccf06d3b54023e7ebf80ad5fce9362bde2 100644 (file)
 #define LLVM_SYSTEM_PATH_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/TimeValue.h"
 #include <set>
 #include <string>
 #include <vector>
 
+#define LLVMV_PATH_DEPRECATED_MSG \
+  "PathV1 is being deprecated, please use the PathV2 API."
+
 namespace llvm {
 namespace sys {
 
@@ -300,12 +304,12 @@ namespace sys {
       /// This function determines if the path name is absolute, as opposed to
       /// relative.
       /// @brief Determine if the path is absolute.
-      bool isAbsolute() const;
+      LLVM_ATTRIBUTE_DEPRECATED(bool isAbsolute() const, LLVMV_PATH_DEPRECATED_MSG);
 
       /// This function determines if the path name is absolute, as opposed to
       /// relative.
       /// @brief Determine if the path is absolute.
-      static bool isAbsolute(const char *NameStart, unsigned NameLen);
+      LLVM_ATTRIBUTE_DEPRECATED(static bool isAbsolute(const char *NameStart, unsigned NameLen), LLVMV_PATH_DEPRECATED_MSG);
 
       /// This function opens the file associated with the path name provided by
       /// the Path object and reads its magic number. If the magic number at the
index dcb0c57649f973a6ed6a547081cdb9570644d469..a8d625c7ac04ce431bf560c24d57e6da99e86089 100644 (file)
@@ -56,7 +56,7 @@ namespace {
   int ExecuteProgram (const std::string& name, const StrVector& args) {
     sys::Path prog(name);
 
-    if (!prog.isAbsolute()) {
+    if (sys::path::is_relative(prog.str())) {
       prog = PrependMainExecutablePath(name, ProgramName,
                                        (void *)(intptr_t)&Main);