summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-25 22:23:04 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-25 22:23:04 +0000
commit3f0a9af13bec64f3bc4bee06a57e18feeb766570 (patch)
tree9de885f1be5c4621a2c98e276f3f2e62324947e8 /include
parent9c256eccb355fb26072ad5353a2f886f62118aa8 (diff)
downloadllvm-3f0a9af13bec64f3bc4bee06a57e18feeb766570.tar.gz
llvm-3f0a9af13bec64f3bc4bee06a57e18feeb766570.tar.bz2
llvm-3f0a9af13bec64f3bc4bee06a57e18feeb766570.tar.xz
Fix resetting the DataLayout in a Module.
No tool does this currently, but as everything else in a module we should be able to change its DataLayout. Most of the fix is in DataLayout to make sure it can be reset properly. The test uses Module::setDataLayout since the fact that we mutate a DataLayout is an implementation detail. The module could hold a OwningPtr<DataLayout> and the DataLayout itself could be immutable. Thanks to Philip Reames for pushing me in the right direction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202198 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/IR/DataLayout.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/include/llvm/IR/DataLayout.h b/include/llvm/IR/DataLayout.h
index f9ab9cf94c..046553dc1a 100644
--- a/include/llvm/IR/DataLayout.h
+++ b/include/llvm/IR/DataLayout.h
@@ -110,7 +110,7 @@ private:
/// Alignments - Where the primitive type alignment data is stored.
///
- /// @sa init().
+ /// @sa reset().
/// @note Could support multiple size pointer alignments, e.g., 32-bit
/// pointers vs. 64-bit pointers by extending LayoutAlignment, but for now,
/// we don't.
@@ -161,30 +161,35 @@ private:
/// malformed.
void parseSpecifier(StringRef LayoutDescription);
+ // Free all internal data structures.
+ void clear();
+
public:
- /// Constructs a DataLayout from a specification string. See init().
- explicit DataLayout(StringRef LayoutDescription) { init(LayoutDescription); }
+ /// Constructs a DataLayout from a specification string. See reset().
+ explicit DataLayout(StringRef LayoutDescription) : LayoutMap(0) {
+ reset(LayoutDescription);
+ }
/// Initialize target data from properties stored in the module.
explicit DataLayout(const Module *M);
- DataLayout(const DataLayout &DL) { *this = DL; }
+ DataLayout(const DataLayout &DL) : LayoutMap(0) { *this = DL; }
DataLayout &operator=(const DataLayout &DL) {
+ clear();
LittleEndian = DL.isLittleEndian();
StackNaturalAlign = DL.StackNaturalAlign;
ManglingMode = DL.ManglingMode;
LegalIntWidths = DL.LegalIntWidths;
Alignments = DL.Alignments;
Pointers = DL.Pointers;
- LayoutMap = 0;
return *this;
}
~DataLayout(); // Not virtual, do not subclass this class
/// Parse a data layout string (with fallback to default values).
- void init(StringRef LayoutDescription);
+ void reset(StringRef LayoutDescription);
/// Layout endianness...
bool isLittleEndian() const { return LittleEndian; }