Skip to content

Commit dd4cc19

Browse files
committed
Add docs and conform to the existing code style (capitalize variable names).
1 parent ab9b28f commit dd4cc19

File tree

2 files changed

+46
-28
lines changed

2 files changed

+46
-28
lines changed

clang/include/clang-c/Dependencies.h

+20-1
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,29 @@ CINDEX_LINKAGE void
325325
clang_experimental_DependencyScannerWorkerScanSettings_dispose(
326326
CXDependencyScannerWorkerScanSettings);
327327

328+
/**
329+
* Generates a reproducer to compile a requested file with required modules.
330+
*
331+
* Here the reproducer means the required input data with the commands to
332+
* compile intermediate modules and a requested file. Required intermediate
333+
* modules and the order of their compilation are determined by the function
334+
* and don't need to be provided.
335+
*
336+
* \param argc the number of compiler invocation arguments (including argv[0]).
337+
* \param argv the compiler driver invocation arguments (including argv[0]).
338+
* \param WorkingDirectory the directory in which the invocation runs.
339+
* \param [out] MessageOut A pointer to store the human-readable message
340+
* describing the result of the operation. If non-NULL,
341+
* owned and should be disposed by the caller.
342+
*
343+
* \returns \c CXError_Success on success; otherwise a non-zero \c CXErrorCode
344+
* indicating the kind of error. \p MessageOut is guaranteed to be populated
345+
* for a success case but is allowed to be empty when encountered an error.
346+
*/
328347
CINDEX_LINKAGE enum CXErrorCode
329348
clang_experimental_DependencyScanner_generateReproducer(
330349
int argc, const char *const *argv, const char *WorkingDirectory,
331-
CXString *messageOut);
350+
CXString *MessageOut);
332351

333352
/**
334353
* Produces the dependency graph for a particular compiler invocation.

clang/tools/libclang/CDependencies.cpp

+26-27
Original file line numberDiff line numberDiff line change
@@ -345,18 +345,18 @@ class MessageEmitter {
345345

346346
enum CXErrorCode clang_experimental_DependencyScanner_generateReproducer(
347347
int argc, const char *const *argv, const char *WorkingDirectory,
348-
CXString *messageOut) {
349-
auto report = [messageOut](CXErrorCode errorCode) -> MessageEmitter {
350-
return MessageEmitter(errorCode, messageOut);
348+
CXString *MessageOut) {
349+
auto Report = [MessageOut](CXErrorCode ErrorCode) -> MessageEmitter {
350+
return MessageEmitter(ErrorCode, MessageOut);
351351
};
352-
auto reportFailure = [&report]() -> MessageEmitter {
353-
return report(CXError_Failure);
352+
auto ReportFailure = [&Report]() -> MessageEmitter {
353+
return Report(CXError_Failure);
354354
};
355355

356356
if (argc < 2 || !argv)
357-
return report(CXError_InvalidArguments) << "missing compilation command";
357+
return Report(CXError_InvalidArguments) << "missing compilation command";
358358
if (!WorkingDirectory)
359-
return report(CXError_InvalidArguments) << "missing working directory";
359+
return Report(CXError_InvalidArguments) << "missing working directory";
360360

361361
CASOptions CASOpts;
362362
IntrusiveRefCntPtr<llvm::cas::CachingOnDiskFileSystem> FS;
@@ -369,7 +369,7 @@ enum CXErrorCode clang_experimental_DependencyScanner_generateReproducer(
369369
int ScriptFD;
370370
if (auto EC = llvm::sys::fs::createTemporaryFile("reproducer", "sh", ScriptFD,
371371
ReproScriptPath)) {
372-
return reportFailure() << "failed to create a reproducer script file";
372+
return ReportFailure() << "failed to create a reproducer script file";
373373
}
374374
SmallString<128> FileCachePath = ReproScriptPath;
375375
llvm::sys::path::replace_extension(FileCachePath, ".cache");
@@ -388,15 +388,14 @@ enum CXErrorCode clang_experimental_DependencyScanner_generateReproducer(
388388
auto TUDepsOrErr = DepsTool.getTranslationUnitDependencies(
389389
Compilation, WorkingDirectory, AlreadySeen, std::move(LookupOutput));
390390
if (!TUDepsOrErr)
391-
return reportFailure() << "failed to generate a reproducer\n"
391+
return ReportFailure() << "failed to generate a reproducer\n"
392392
<< toString(TUDepsOrErr.takeError());
393393

394394
TranslationUnitDeps TU = *TUDepsOrErr;
395395
llvm::raw_fd_ostream ScriptOS(ScriptFD, /*shouldClose=*/true);
396396
ScriptOS << "# Original command:\n#";
397-
for (StringRef cliArg : Compilation) {
398-
ScriptOS << ' ' << cliArg;
399-
}
397+
for (StringRef Arg : Compilation)
398+
ScriptOS << ' ' << Arg;
400399
ScriptOS << "\n\n";
401400

402401
ScriptOS << "# Dependencies:\n";
@@ -410,34 +409,34 @@ enum CXErrorCode clang_experimental_DependencyScanner_generateReproducer(
410409
OS << " -ivfsoverlay \"" << FileCacheName << "/vfs/vfs.yaml\"";
411410
OS << '\n';
412411
};
413-
for (ModuleDeps &dep : TU.ModuleGraph)
414-
PrintArguments(ScriptOS, dep.getBuildArguments());
412+
for (ModuleDeps &Dep : TU.ModuleGraph)
413+
PrintArguments(ScriptOS, Dep.getBuildArguments());
415414
ScriptOS << "\n# Translation unit:\n";
416-
for (const Command &buildCommand : TU.Commands)
417-
PrintArguments(ScriptOS, buildCommand.Arguments);
415+
for (const Command &BuildCommand : TU.Commands)
416+
PrintArguments(ScriptOS, BuildCommand.Arguments);
418417

419418
SmallString<128> VFSCachePath = FileCachePath;
420419
llvm::sys::path::append(VFSCachePath, "vfs");
421420
std::string VFSCachePathStr = VFSCachePath.str().str();
422-
llvm::FileCollector fileCollector(VFSCachePathStr,
421+
llvm::FileCollector FileCollector(VFSCachePathStr,
423422
/*OverlayRoot=*/VFSCachePathStr);
424-
for (const auto &fileDep : TU.FileDeps) {
425-
fileCollector.addFile(fileDep);
423+
for (const auto &FileDep : TU.FileDeps) {
424+
FileCollector.addFile(FileDep);
426425
}
427-
for (ModuleDeps &dep : TU.ModuleGraph) {
428-
dep.forEachFileDep([&fileCollector](StringRef fileDep) {
429-
fileCollector.addFile(fileDep);
426+
for (ModuleDeps &ModuleDep : TU.ModuleGraph) {
427+
ModuleDep.forEachFileDep([&FileCollector](StringRef FileDep) {
428+
FileCollector.addFile(FileDep);
430429
});
431430
}
432-
if (fileCollector.copyFiles(/*StopOnError=*/true))
433-
return reportFailure()
431+
if (FileCollector.copyFiles(/*StopOnError=*/true))
432+
return ReportFailure()
434433
<< "failed to copy the files used for the compilation";
435434
SmallString<128> VFSOverlayPath = VFSCachePath;
436435
llvm::sys::path::append(VFSOverlayPath, "vfs.yaml");
437-
if (fileCollector.writeMapping(VFSOverlayPath))
438-
return reportFailure() << "failed to write a VFS overlay mapping";
436+
if (FileCollector.writeMapping(VFSOverlayPath))
437+
return ReportFailure() << "failed to write a VFS overlay mapping";
439438

440-
return report(CXError_Success)
439+
return Report(CXError_Success)
441440
<< "Created a reproducer. Sources and associated run script(s) are "
442441
"located at:\n "
443442
<< FileCachePath << "\n " << ReproScriptPath;

0 commit comments

Comments
 (0)