diff options
author | Gabor Greif <ggreif@gmail.com> | 2008-10-17 08:31:36 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2008-10-17 08:31:36 +0000 |
commit | 97966407d04663cc837771e9bcf2c10100d719f8 (patch) | |
tree | 7bc25151d5df53b12ae9c17d97a35fdb8ee33a93 | |
parent | 3cd9a29c64700ec31f12fc6813dc63e951af730f (diff) | |
download | bcm5719-llvm-97966407d04663cc837771e9bcf2c10100d719f8.tar.gz bcm5719-llvm-97966407d04663cc837771e9bcf2c10100d719f8.zip |
Add comment on how tagged pointers are
distinguished from normal (untagged) ones
as per review comment.
I am sufficiently unaquainted with doxygen to
defer the markup to someone with more experience.
llvm-svn: 57676
-rw-r--r-- | llvm/include/llvm/Use.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/include/llvm/Use.h b/llvm/include/llvm/Use.h index f88d4357c77..b4d2c488243 100644 --- a/llvm/include/llvm/Use.h +++ b/llvm/include/llvm/Use.h @@ -29,13 +29,20 @@ class User; // Generic Tagging Functions //===----------------------------------------------------------------------===// +// We adhere to the following convention: The type of a tagged pointer +// to T is T volatile*. This means that functions that superpose a tag +// on a pointer will be supplied a T* (or T const*) and will return a +// tagged one: T volatile*. Untagging functions do it the other way +// 'round. While this scheme does not prevent dereferencing of tagged +// pointers, proper type annotations do catch most inappropriate uses. + /// Tag - generic tag type for (at least 32 bit) pointers enum Tag { noTag, tagOne, tagTwo, tagThree }; /// addTag - insert tag bits into an (untagged) pointer template <typename T, typename TAG> inline volatile T *addTag(const T *P, TAG Tag) { - return reinterpret_cast<T*>(ptrdiff_t(P) | Tag); + return reinterpret_cast<T*>(ptrdiff_t(P) | Tag); } /// stripTag - remove tag bits from a pointer, |