std::string TempFilename;
std::unique_ptr<raw_ostream> OS;
- OutputFile(const std::string &filename, const std::string &tempFilename,
+ OutputFile(std::string filename, std::string tempFilename,
std::unique_ptr<raw_ostream> OS)
- : Filename(filename), TempFilename(tempFilename), OS(std::move(OS)) {}
+ : Filename(std::move(filename)), TempFilename(std::move(tempFilename)),
+ OS(std::move(OS)) {}
OutputFile(OutputFile &&O)
: Filename(std::move(O.Filename)),
TempFilename(std::move(O.TempFilename)), OS(std::move(O.OS)) {}
///
/// \return - The new object on success, or null on failure.
static IntrusiveRefCntPtr<ASTReader> createPCHExternalASTSource(
- StringRef Path, const std::string &Sysroot, bool DisablePCHValidation,
+ StringRef Path, StringRef Sysroot, bool DisablePCHValidation,
bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context,
const PCHContainerOperations &PCHContainerOps,
void *DeserializationListener, bool OwnDeserializationListener,
/// Create a code completion consumer to print code completion results, at
/// \p Filename, \p Line, and \p Column, to the given output stream \p OS.
- static CodeCompleteConsumer *
- createCodeCompletionConsumer(Preprocessor &PP, const std::string &Filename,
- unsigned Line, unsigned Column,
- const CodeCompleteOptions &Opts,
- raw_ostream &OS);
+ static CodeCompleteConsumer *createCodeCompletionConsumer(
+ Preprocessor &PP, StringRef Filename, unsigned Line, unsigned Column,
+ const CodeCompleteOptions &Opts, raw_ostream &OS);
/// \brief Create the Sema object to be used for parsing.
void createSema(TranslationUnitKind TUKind,
TEST_F(RegistryTest, ConstructWithSimpleArgs) {
Matcher<Decl> Value = constructMatcher(
- "namedDecl", constructMatcher("hasName", std::string("X")))
+ "namedDecl", constructMatcher("hasName", StringRef("X")))
.getTypedMatcher<Decl>();
EXPECT_TRUE(matches("class X {};", Value));
EXPECT_FALSE(matches("int x;", Value));
Matcher<Decl> HasParameter =
functionDecl(constructMatcher(
- "hasParameter", 1, constructMatcher("hasName", std::string("x")))
+ "hasParameter", 1, constructMatcher("hasName", StringRef("x")))
.getTypedMatcher<FunctionDecl>());
EXPECT_TRUE(matches("void f(int a, int x);", HasParameter));
EXPECT_FALSE(matches("void f(int x, int a);", HasParameter));
constructMatcher(
"callee",
constructMatcher("methodDecl",
- constructMatcher("hasName", std::string("x")))))
+ constructMatcher("hasName", StringRef("x")))))
.getTypedMatcher<Stmt>();
std::string Code = "class Y { public: void x(); }; void z() { Y y; y.x(); }";
Matcher<Decl> DeclDecl = declaratorDecl(hasTypeLoc(
constructMatcher(
- "loc", constructMatcher("asString", std::string("const double *")))
+ "loc", constructMatcher("asString", StringRef("const double *")))
.getTypedMatcher<TypeLoc>()));
Matcher<NestedNameSpecifierLoc> NNSL =
Matcher<Decl> Anything = constructMatcher("anything").getTypedMatcher<Decl>();
Matcher<Decl> RecordDecl = constructMatcher(
- "recordDecl", constructMatcher("hasName", std::string("Foo")),
+ "recordDecl", constructMatcher("hasName", StringRef("Foo")),
VariantMatcher::SingleMatcher(Anything)).getTypedMatcher<Decl>();
EXPECT_TRUE(matches("int Foo;", Anything));
constructMatcher(
"methodDecl",
constructMatcher(
- "ofClass", constructMatcher("hasName", std::string("Foo"))))))
+ "ofClass", constructMatcher("hasName", StringRef("Foo"))))))
.getTypedMatcher<Stmt>();
EXPECT_FALSE(matches("class Foo { public: Foo(); };", ConstructExpr));
EXPECT_TRUE(
constructMatcher(
"hasAnyTemplateArgument",
constructMatcher("refersToType",
- constructMatcher("asString", std::string("int")))))
+ constructMatcher("asString", StringRef("int")))))
.getTypedMatcher<Decl>();
EXPECT_TRUE(matches("template<typename T> class A {}; A<int> a;",
HasTemplateArgument));
constructMatcher(
"hasAnyConstructorInitializer",
constructMatcher("forField",
- constructMatcher("hasName", std::string("foo")))))
+ constructMatcher("hasName", StringRef("foo")))))
.getTypedMatcher<Decl>();
EXPECT_TRUE(matches("struct Foo { Foo() : foo(1) {} int foo; };", CtorDecl));
EXPECT_FALSE(matches("struct Foo { Foo() {} int foo; };", CtorDecl));
constructMatcher(
"has",
constructMatcher("recordDecl",
- constructMatcher("hasName", std::string("X")))))
+ constructMatcher("hasName", StringRef("X")))))
.getTypedMatcher<Decl>();
EXPECT_TRUE(matches("class X {};", D));
EXPECT_TRUE(matches("class Y { class X {}; };", D));
constructMatcher(
"hasDescendant",
constructMatcher("varDecl",
- constructMatcher("hasName", std::string("X")))))
+ constructMatcher("hasName", StringRef("X")))))
.getTypedMatcher<Stmt>();
EXPECT_TRUE(matches("void foo() { for(int X;;); }", S));
EXPECT_TRUE(matches("void foo() { for(;;) { int X; } }", S));
Matcher<Decl> D = constructMatcher(
"anyOf",
constructMatcher("recordDecl",
- constructMatcher("hasName", std::string("Foo"))),
+ constructMatcher("hasName", StringRef("Foo"))),
constructMatcher("functionDecl",
- constructMatcher("hasName", std::string("foo"))))
+ constructMatcher("hasName", StringRef("foo"))))
.getTypedMatcher<Decl>();
EXPECT_TRUE(matches("void foo(){}", D));
constructMatcher(
"namedDecl",
constructMatcher("anyOf",
- constructMatcher("hasName", std::string("Foo")),
- constructMatcher("hasName", std::string("Bar")))))
+ constructMatcher("hasName", StringRef("Foo")),
+ constructMatcher("hasName", StringRef("Bar")))))
.getTypedMatcher<Decl>();
EXPECT_FALSE(matches("void foo(){}", D));
constructMatcher(
"unless",
constructMatcher("namedDecl",
- constructMatcher("hasName", std::string("Bar"))))
+ constructMatcher("hasName", StringRef("Bar"))))
.getTypedMatcher<Decl>());
EXPECT_FALSE(matches("class Bar{ int Foo; };", D));
EXPECT_TRUE(matches("class OtherBar{ int Foo; };", D));
D = constructMatcher(
- "namedDecl", constructMatcher("hasName", std::string("Foo")),
+ "namedDecl", constructMatcher("hasName", StringRef("Foo")),
constructMatcher("unless", constructMatcher("recordDecl")))
.getTypedMatcher<Decl>();
EXPECT_TRUE(matches("void Foo(){}", D));
EXPECT_EQ("Incorrect argument count. (Expected = 1) != (Actual = 0)",
Error->toString());
Error.reset(new Diagnostics());
- EXPECT_TRUE(constructMatcher("isArrow", std::string(), Error.get()).isNull());
+ EXPECT_TRUE(constructMatcher("isArrow", StringRef(), Error.get()).isNull());
EXPECT_EQ("Incorrect argument count. (Expected = 0) != (Actual = 1)",
Error->toString());
Error.reset(new Diagnostics());
EXPECT_EQ("Incorrect argument count. (Expected = (2, )) != (Actual = 0)",
Error->toString());
Error.reset(new Diagnostics());
- EXPECT_TRUE(constructMatcher("unless", std::string(), std::string(),
+ EXPECT_TRUE(constructMatcher("unless", StringRef(), StringRef(),
Error.get()).isNull());
EXPECT_EQ("Incorrect argument count. (Expected = (1, 1)) != (Actual = 2)",
Error->toString());
// Bad argument type
Error.reset(new Diagnostics());
- EXPECT_TRUE(constructMatcher("ofClass", std::string(), Error.get()).isNull());
+ EXPECT_TRUE(constructMatcher("ofClass", StringRef(), Error.get()).isNull());
EXPECT_EQ("Incorrect type for arg 1. (Expected = Matcher<CXXRecordDecl>) != "
"(Actual = String)",
Error->toString());
// Bad argument type with variadic.
Error.reset(new Diagnostics());
- EXPECT_TRUE(constructMatcher("anyOf", std::string(), std::string(),
+ EXPECT_TRUE(constructMatcher("anyOf", StringRef(), StringRef(),
Error.get()).isNull());
EXPECT_EQ(
"Incorrect type for arg 1. (Expected = Matcher<>) != (Actual = String)",
EXPECT_TRUE(constructMatcher(
"recordDecl",
constructMatcher("allOf",
- constructMatcher("isDerivedFrom", std::string("FOO")),
+ constructMatcher("isDerivedFrom", StringRef("FOO")),
constructMatcher("isArrow")),
Error.get()).isNull());
EXPECT_EQ("Incorrect type for arg 1. "
TEST_F(RegistryTest, HasArgs) {
Matcher<Decl> Value = constructMatcher(
- "decl", constructMatcher("hasAttr", std::string("attr::WarnUnused")))
+ "decl", constructMatcher("hasAttr", StringRef("attr::WarnUnused")))
.getTypedMatcher<Decl>();
EXPECT_TRUE(matches("struct __attribute__((warn_unused)) X {};", Value));
EXPECT_FALSE(matches("struct X {};", Value));