aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-06-21 17:26:25 -0600
committerTom Tromey <tom@tromey.com>2021-06-21 17:26:25 -0600
commit3ebfb4d4222d252673ce1afff5a7264e332b3b13 (patch)
tree66e959a411391ee82bcc73871bfbb0e741e2c06c /gcc
parentf2d9faf3862a75247adbd6c233c889010902a34b (diff)
downloadgcc-3ebfb4d4222d252673ce1afff5a7264e332b3b13.zip
gcc-3ebfb4d4222d252673ce1afff5a7264e332b3b13.tar.gz
gcc-3ebfb4d4222d252673ce1afff5a7264e332b3b13.tar.bz2
Use unique_ptr in Token
Token currently uses a "std::string *". There's a comment proposing that perhaps this should be changed; but meanwhile, it's slightly cleaner to use unique_ptr rather than have Token manage the string's lifetime manually.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/lex/rust-token.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/rust/lex/rust-token.h b/gcc/rust/lex/rust-token.h
index f76899c..5526a28 100644
--- a/gcc/rust/lex/rust-token.h
+++ b/gcc/rust/lex/rust-token.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2020 Free Software Foundation, Inc.
+// Copyright (C) 2020, 2021 Free Software Foundation, Inc.
// This file is part of GCC.
@@ -249,7 +249,7 @@ private:
// Token location.
Location locus;
// Associated text (if any) of token.
- std::string *str;
+ std::unique_ptr<std::string> str;
// TODO: maybe remove issues and just store std::string as value?
/* Type hint for token based on lexer data (e.g. type suffix). Does not exist
* for most tokens. */
@@ -298,7 +298,7 @@ public:
Token (Token &&other) = default;
Token &operator= (Token &&other) = default;
- ~Token () { delete str; }
+ ~Token () = default;
/* TODO: make_shared (which saves a heap allocation) does not work with the
* private constructor */