Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[5.9] [clang] NFC: A couple of test fixes #7047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Frontend/ASTUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ class ASTUnit {
///
// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
// shouldn't need to specify them at construction time.
static ASTUnit *LoadFromCommandLine(
static std::unique_ptr<ASTUnit> LoadFromCommandLine(
const char **ArgBegin, const char **ArgEnd,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CrossTU/CrossTranslationUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,10 @@ CrossTranslationUnitContext::ASTLoader::loadFromSource(
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
new DiagnosticsEngine{DiagID, &*DiagOpts, DiagClient});

return std::unique_ptr<ASTUnit>(ASTUnit::LoadFromCommandLine(
return ASTUnit::LoadFromCommandLine(
CommandLineArgs.begin(), (CommandLineArgs.end()),
CI.getPCHContainerOperations(), Diags,
CI.getHeaderSearchOpts().ResourceDir));
CI.getHeaderSearchOpts().ResourceDir);
}

llvm::Expected<InvocationListTy>
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Frontend/ASTUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
return AST;
}

ASTUnit *ASTUnit::LoadFromCommandLine(
std::unique_ptr<ASTUnit> ASTUnit::LoadFromCommandLine(
const char **ArgBegin, const char **ArgEnd,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
Expand Down Expand Up @@ -1841,7 +1841,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
return nullptr;
}

return AST.release();
return AST;
}

bool ASTUnit::Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
Expand Down
4 changes: 2 additions & 2 deletions clang/tools/libclang/CIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3872,7 +3872,7 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
*CXXIdx, source_filename,
LibclangInvocationReporter::OperationKind::ParseOperation, options,
llvm::makeArrayRef(*Args), /*InvocationArgs=*/None, unsaved_files);
std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCommandLine(
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromCommandLine(
Args->data(), Args->data() + Args->size(),
CXXIdx->getPCHContainerOperations(), Diags,
CXXIdx->getClangResourcesPath(), CXXIdx->getOnlyLocalDecls(),
Expand All @@ -3882,7 +3882,7 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
/*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
/*UserFilesAreVolatile=*/true, ForSerialization, RetainExcludedCB,
CXXIdx->getPCHContainerOperations()->getRawReader().getFormat(),
&ErrUnit));
&ErrUnit);

// Early failures in LoadFromCommandLine may return with ErrUnit unset.
if (!Unit && !ErrUnit)
Expand Down
4 changes: 2 additions & 2 deletions clang/unittests/Frontend/ASTUnitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ TEST_F(ASTUnitTest, LoadFromCommandLineEarlyError) {
auto PCHContainerOps = std::make_shared<PCHContainerOperations>();
std::unique_ptr<clang::ASTUnit> ErrUnit;

ASTUnit *AST = ASTUnit::LoadFromCommandLine(
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCommandLine(
&Args[0], &Args[4], PCHContainerOps, Diags, "", false,
CaptureDiagsKind::All, None, true, 0, TU_Complete, false, false, false,
SkipFunctionBodiesScope::None, false, true, false, false, None, &ErrUnit,
Expand All @@ -193,7 +193,7 @@ TEST_F(ASTUnitTest, LoadFromCommandLineWorkingDirectory) {
auto PCHContainerOps = std::make_shared<PCHContainerOperations>();
std::unique_ptr<clang::ASTUnit> ErrUnit;

auto *AST = ASTUnit::LoadFromCommandLine(
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCommandLine(
&Args[0], &Args[4], PCHContainerOps, Diags, "", false,
CaptureDiagsKind::All, None, true, 0, TU_Complete, false, false, false,
SkipFunctionBodiesScope::None, false, true, false, false, None, &ErrUnit,
Expand Down
12 changes: 7 additions & 5 deletions clang/unittests/Frontend/ReparseWorkingDirTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ class ReparseWorkingDirTest : public ::testing::Test {
};

TEST_F(ReparseWorkingDirTest, ReparseWorkingDir) {
// Setup the working directory path. We use '//root/' to allow the path to be
// valid on both Windows and Unix. We need the trailing slash for the path
// to be treated as absolute.
// Setup the working directory path.
SmallString<16> WorkingDir;
llvm::sys::path::append(WorkingDir, "//root",
llvm::sys::path::get_separator());
#ifdef _WIN32
WorkingDir = "C:\\";
#else
WorkingDir = "/";
#endif
llvm::sys::path::append(WorkingDir, "root");
setWorkingDirectory(WorkingDir);

SmallString<32> Header;
Expand Down