]> granicus.if.org Git - clang/commitdiff
TargetInfo objects now own the TargetInfoImpl objects they refer to.
authorTed Kremenek <kremenek@apple.com>
Tue, 4 Mar 2008 17:47:18 +0000 (17:47 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 4 Mar 2008 17:47:18 +0000 (17:47 +0000)
TargetInfo::AddSecondaryTarget is now private, as it is only used during
object construction.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@47891 91177308-0d34-0410-b5e6-96231b3b80d8

Basic/Targets.cpp
include/clang/Basic/TargetInfo.h

index f77bef185a333a9882029e40e2fb9cb8a1e0b3cf..d87e386fa996488df06a6248530566306a5523c2 100644 (file)
@@ -826,3 +826,10 @@ TargetInfo* TargetInfo::CreateTargetInfo(const std::string* TriplesStart,
   
   return TI;
 }
+
+TargetInfo::~TargetInfo() {
+  delete PrimaryTarget;
+  for (unsigned i = 0; i < SecondaryTargets.size(); ++i)
+    delete SecondaryTargets[i];
+}
+
index 6d4147c35353242ebc8ed89893ae4a1a9e1f3cd1..0550e51e82b06dc423e66749870a53a2d18c657a 100644 (file)
@@ -38,9 +38,6 @@ namespace Builtin { struct Info; }
 /// target, it will warn the first time the size of the 'long' datatype is
 /// queried.
 ///
-/// Note that TargetInfo does not take ownership of the various targets or the 
-/// diagnostic info, but does expect them to be alive for as long as it is.
-///
 class TargetInfo {
   /// Primary - This tracks the primary target in the target set.
   ///
@@ -75,6 +72,11 @@ class TargetInfo {
     WCharWidth = 0;
   }
 
+  /// AddSecondaryTarget - Add a secondary target to the target set.
+  void AddSecondaryTarget(const TargetInfoImpl *Secondary) {
+    SecondaryTargets.push_back(Secondary);
+  }
+
 public:  
   /// CreateTargetInfo - Create a TargetInfo object from a group of
   ///  target triples.  The first target triple is considered the primary
@@ -83,6 +85,8 @@ public:
                                       const std::string* TripledEnd,
                                       Diagnostic* Diags = NULL);
 
+  ~TargetInfo();
+
   //==----------------------------------------------------------------==/
   //                       Accessors.
   //==----------------------------------------------------------------==/  
@@ -99,11 +103,6 @@ public:
     return !NonPortable;
   }
   
-  /// AddSecondaryTarget - Add a secondary target to the target set.
-  void AddSecondaryTarget(const TargetInfoImpl *Secondary) {
-    SecondaryTargets.push_back(Secondary);
-  }
-  
   ///===---- Target property query methods --------------------------------===//
 
   /// DiagnoseNonPortability - Emit a diagnostic indicating that the current