[cfe-commits] r47891 - in /cfe/trunk: Basic/Targets.cpp include/clang/Basic/TargetInfo.h

Ted Kremenek kremenek at apple.com
Tue Mar 4 09:47:19 PST 2008


Author: kremenek
Date: Tue Mar  4 11:47:18 2008
New Revision: 47891

URL: http://llvm.org/viewvc/llvm-project?rev=47891&view=rev
Log:
TargetInfo objects now own the TargetInfoImpl objects they refer to.
TargetInfo::AddSecondaryTarget is now private, as it is only used during
object construction.

Modified:
    cfe/trunk/Basic/Targets.cpp
    cfe/trunk/include/clang/Basic/TargetInfo.h

Modified: cfe/trunk/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/Targets.cpp?rev=47891&r1=47890&r2=47891&view=diff

==============================================================================
--- cfe/trunk/Basic/Targets.cpp (original)
+++ cfe/trunk/Basic/Targets.cpp Tue Mar  4 11:47:18 2008
@@ -826,3 +826,10 @@
   
   return TI;
 }
+
+TargetInfo::~TargetInfo() {
+  delete PrimaryTarget;
+  for (unsigned i = 0; i < SecondaryTargets.size(); ++i)
+    delete SecondaryTargets[i];
+}
+

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=47891&r1=47890&r2=47891&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Mar  4 11:47:18 2008
@@ -38,9 +38,6 @@
 /// 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 @@
     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 @@
                                       const std::string* TripledEnd,
                                       Diagnostic* Diags = NULL);
 
+  ~TargetInfo();
+
   //==----------------------------------------------------------------==/
   //                       Accessors.
   //==----------------------------------------------------------------==/  
@@ -99,11 +103,6 @@
     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





More information about the cfe-commits mailing list