+++ /dev/null
-/*===-- clang-c/ARCMigrate.h - ARC Migration Public C Interface ---*- C -*-===*\
-|* *|
-|* The LLVM Compiler Infrastructure *|
-|* *|
-|* This file is distributed under the University of Illinois Open Source *|
-|* License. See LICENSE.TXT for details. *|
-|* *|
-|*===----------------------------------------------------------------------===*|
-|* *|
-|* This header provides a public interface to a Clang library for migrating *|
-|* objective-c source files to ARC mode. *|
-|* *|
-\*===----------------------------------------------------------------------===*/
-
-#ifndef CLANG_C_ARCMIGRATE_H
-#define CLANG_C_ARCMIGRATE_H
-
-#include "clang-c/Index.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/** \defgroup CARCMT libclang: C Interface to Clang ARC migration library
- *
- * The C Interface provides a small API that exposes facilities for translating
- * objective-c source files of a project to Automatic Reference Counting mode.
- *
- * To avoid namespace pollution, data types are prefixed with "CMT" and
- * functions are prefixed with "arcmt_".
- *
- * @{
- */
-
-/**
- * \brief A remapping of original source files and their translated files.
- */
-typedef void *CMTRemap;
-
-/**
- * \brief Retrieve a remapping.
- *
- * \param migrate_dir_path the path that clang used during the migration process.
- *
- * \returns the requested remapping. This remapping must be freed
- * via a call to \c arcmt_remap_dispose(). Can return NULL if an error occurred.
- */
-CINDEX_LINKAGE CMTRemap arcmt_getRemappings(const char *migrate_dir_path);
-
-/**
- * \brief Determine the number of remappings.
- */
-CINDEX_LINKAGE unsigned arcmt_remap_getNumFiles(CMTRemap);
-
-/**
- * \brief Get the original filename.
- */
-CINDEX_LINKAGE CXString arcmt_remap_getOriginalFile(CMTRemap, unsigned index);
-
-/**
- * \brief Get the filename that the original file was translated into.
- */
-CINDEX_LINKAGE
-CXString arcmt_remap_getTransformedFile(CMTRemap, unsigned index);
-
-/**
- * \brief Dispose the remapping.
- */
-CINDEX_LINKAGE void arcmt_remap_dispose(CMTRemap);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-#endif
-
CXInclusionVisitor visitor,
CXClientData client_data);
+/**
+ * @}
+ */
+
+/** \defgroup CINDEX_REMAPPING Remapping functions
+ *
+ * @{
+ */
+
+/**
+ * \brief A remapping of original source files and their translated files.
+ */
+typedef void *CXRemapping;
+
+/**
+ * \brief Retrieve a remapping.
+ *
+ * \param path the path that contains metadata about remappings.
+ *
+ * \returns the requested remapping. This remapping must be freed
+ * via a call to \c clang_remap_dispose(). Can return NULL if an error occurred.
+ */
+CINDEX_LINKAGE CXRemapping clang_getRemappings(const char *path);
+
+/**
+ * \brief Determine the number of remappings.
+ */
+CINDEX_LINKAGE unsigned clang_remap_getNumFiles(CXRemapping);
+
+/**
+ * \brief Get the original and the associated filename from the remapping.
+ *
+ * \param original If non-NULL, will be set to the original filename.
+ *
+ * \param transformed If non-NULL, will be set to the filename that the original
+ * is associated with.
+ */
+CINDEX_LINKAGE void clang_remap_getFilenames(CXRemapping, unsigned index,
+ CXString *original, CXString *transformed);
+
+/**
+ * \brief Dispose the remapping.
+ */
+CINDEX_LINKAGE void clang_remap_dispose(CXRemapping);
+
/**
* @}
*/
/* c-arcmt-test.c */
-#include "clang-c/ARCMigrate.h"
+#include "clang-c/Index.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#endif
static int print_remappings(const char *path) {
- CMTRemap remap;
+ CXRemapping remap;
unsigned i, N;
CXString origFname;
CXString transFname;
- remap = arcmt_getRemappings(path);
+ remap = clang_getRemappings(path);
if (!remap)
return 1;
- N = arcmt_remap_getNumFiles(remap);
+ N = clang_remap_getNumFiles(remap);
for (i = 0; i != N; ++i) {
- origFname = arcmt_remap_getOriginalFile(remap, i);
- transFname = arcmt_remap_getTransformedFile(remap, i);
+ clang_remap_getFilenames(remap, i, &origFname, &transFname);
fprintf(stdout, "%s\n", clang_getCString(origFname));
fprintf(stdout, "%s\n", clang_getCString(transFname));
clang_disposeString(transFname);
}
- arcmt_remap_dispose(remap);
+ clang_remap_dispose(remap);
return 0;
}
//
//===----------------------------------------------------------------------===//
-#include "clang-c/ARCMigrate.h"
+#include "clang-c/Index.h"
#include "CXString.h"
#include "clang/ARCMigrate/ARCMT.h"
extern "C" {
-CMTRemap arcmt_getRemappings(const char *migrate_dir_path) {
+CXRemapping clang_getRemappings(const char *migrate_dir_path) {
bool Logging = ::getenv("LIBCLANG_LOGGING");
if (!migrate_dir_path) {
if (Logging)
- llvm::errs() << "arcmt_getRemappings was called with NULL parameter\n";
+ llvm::errs() << "clang_getRemappings was called with NULL parameter\n";
return 0;
}
llvm::sys::fs::exists(migrate_dir_path, exists);
if (!exists) {
if (Logging) {
- llvm::errs() << "Error by arcmt_getRemappings(\"" << migrate_dir_path
+ llvm::errs() << "Error by clang_getRemappings(\"" << migrate_dir_path
<< "\")\n";
llvm::errs() << "\"" << migrate_dir_path << "\" does not exist\n";
}
if (err) {
if (Logging) {
- llvm::errs() << "Error by arcmt_getRemappings(\"" << migrate_dir_path
+ llvm::errs() << "Error by clang_getRemappings(\"" << migrate_dir_path
<< "\")\n";
for (TextDiagnosticBuffer::const_iterator
I = diagBuffer.err_begin(), E = diagBuffer.err_end(); I != E; ++I)
return remap.take();
}
-unsigned arcmt_remap_getNumFiles(CMTRemap map) {
+unsigned clang_remap_getNumFiles(CXRemapping map) {
return static_cast<Remap *>(map)->Vec.size();
}
-CXString arcmt_remap_getOriginalFile(CMTRemap map, unsigned index) {
- return cxstring::createCXString(static_cast<Remap *>(map)->Vec[index].first,
+void clang_remap_getFilenames(CXRemapping map, unsigned index,
+ CXString *original, CXString *transformed) {
+ if (original)
+ *original = cxstring::createCXString(
+ static_cast<Remap *>(map)->Vec[index].first,
+ /*DupString =*/ true);
+ if (transformed)
+ *transformed = cxstring::createCXString(
+ static_cast<Remap *>(map)->Vec[index].second,
/*DupString =*/ true);
}
-CXString arcmt_remap_getTransformedFile(CMTRemap map, unsigned index) {
- return cxstring::createCXString(static_cast<Remap *>(map)->Vec[index].second,
- /*DupString =*/ true);
-}
-
-void arcmt_remap_dispose(CMTRemap map) {
+void clang_remap_dispose(CXRemapping map) {
delete static_cast<Remap *>(map);
}
_clang_tokenize
_clang_visitChildren
_clang_visitChildrenWithBlock
-_arcmt_getRemappings
-_arcmt_remap_getNumFiles
-_arcmt_remap_getOriginalFile
-_arcmt_remap_getTransformedFile
-_arcmt_remap_dispose
+_clang_getRemappings
+_clang_remap_getNumFiles
+_clang_remap_getFilenames
+_clang_remap_dispose
clang_tokenize
clang_visitChildren
clang_visitChildrenWithBlock
-arcmt_getRemappings
-arcmt_remap_getNumFiles
-arcmt_remap_getOriginalFile
-arcmt_remap_getTransformedFile
-arcmt_remap_dispose
+clang_getRemappings
+clang_remap_getNumFiles
+clang_remap_getFilenames
+clang_remap_dispose