2014-07-08 23:41:20 +08:00
|
|
|
// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-twine-local %t
|
|
|
|
// REQUIRES: shell
|
2014-07-08 22:32:17 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class Twine {
|
|
|
|
public:
|
|
|
|
Twine(const char *);
|
|
|
|
Twine(int);
|
|
|
|
Twine &operator+(const Twine &);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
void foo(const Twine &x);
|
|
|
|
|
|
|
|
static Twine Moo = Twine("bark") + "bah";
|
2014-07-11 21:44:51 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to use-after-free bugs
|
2014-07-08 22:32:17 +08:00
|
|
|
// CHECK-MESSAGES: note: FIX-IT applied suggested code changes
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-FIXES: static std::string Moo = (Twine("bark") + "bah").str();
|
2014-07-08 22:32:17 +08:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
const Twine t = Twine("a") + "b" + Twine(42);
|
2014-07-11 21:44:51 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: twine variables are prone to use-after-free bugs
|
2014-07-08 22:32:17 +08:00
|
|
|
// CHECK-MESSAGES: note: FIX-IT applied suggested code changes
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-FIXES: std::string t = (Twine("a") + "b" + Twine(42)).str();
|
2014-07-08 22:32:17 +08:00
|
|
|
foo(Twine("a") + "b");
|
|
|
|
|
|
|
|
Twine Prefix = false ? "__INT_FAST" : "__UINT_FAST";
|
2014-07-11 21:44:51 +08:00
|
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: twine variables are prone to use-after-free bugs
|
2014-07-08 22:32:17 +08:00
|
|
|
// CHECK-MESSAGES: note: FIX-IT applied suggested code changes
|
2014-07-10 05:09:26 +08:00
|
|
|
// CHECK-FIXES: const char * Prefix = false ? "__INT_FAST" : "__UINT_FAST";
|
2014-07-08 22:32:17 +08:00
|
|
|
}
|