Skip to content

Fix bug with -fcas-emit-casid-file during replay. #8340

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
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
7 changes: 5 additions & 2 deletions clang/lib/CodeGen/CodeGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,11 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
BA == Backend_EmitObj && OutputFile != "-") {
std::string OutputPathCASIDFile = std::string(OutputFile);
OutputPathCASIDFile.append(".casid");
CasIDOS = CI.createOutputFile(OutputPathCASIDFile, true, true,
CI.getFrontendOpts().UseTemporary, false);
std::error_code EC;
CasIDOS = std::make_unique<raw_fd_ostream>(OutputPathCASIDFile, EC);
if (EC)
CI.getDiagnostics().Report(diag::err_fe_unable_to_open_output)
<< EC.message();
}
}

Expand Down
16 changes: 16 additions & 0 deletions clang/test/CAS/mccas-emit-casid-file.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// REQUIRES: x86-registered-target
// RUN: rm -rf %t && mkdir %t

// RUN: %clang -cc1depscan -o %t/args.rsp -cc1-args -cc1 -triple x86_64-apple-darwin10 \
// RUN: -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb \
// RUN: -emit-obj -fcas-backend -fcas-path %t/cas -fcas-emit-casid-file %s

// RUN: %clang @%t/args.rsp -o %t/output1.o

// cat %t/output1.o.casid | FileCheck %s

// CHECK: llvmcas://{{[a-z0-9]+}}

int foo(int x) {
return x+1;
}
7 changes: 4 additions & 3 deletions llvm/lib/MC/MachOCASWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ uint64_t MachOCASWriter::writeObject(MCAssembler &Asm,

return Error::success();
};

if (CasIDOS)
writeCASIDBuffer(CASObj.getID(), *CasIDOS);

// If there is a callback, then just hand off the result through callback.
if (ResultCallBack) {
cantFail((*ResultCallBack)(CASObj.getID()));
Expand Down Expand Up @@ -115,9 +119,6 @@ uint64_t MachOCASWriter::writeObject(MCAssembler &Asm,
}
}

if (CasIDOS)
writeCASIDBuffer(CASObj.getID(), *CasIDOS);

return OS.tell() - StartOffset;
}

Expand Down