[libclang] Remove the 'extern "C"' blocks from the implementation files.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 17 Dec 2016 01:09:40 +0000 (01:09 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 17 Dec 2016 01:09:40 +0000 (01:09 +0000)
These are unnecessary, the declarations already carry the 'extern C' property, and if there is mismatch
between declaration and definition then we will get linker errors via libclang.exports.

llvm-svn: 290025

16 files changed:
clang/tools/libclang/ARCMigrate.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CIndexCXX.cpp
clang/tools/libclang/CIndexCodeCompletion.cpp
clang/tools/libclang/CIndexDiagnostic.cpp
clang/tools/libclang/CIndexHigh.cpp
clang/tools/libclang/CIndexInclusionStack.cpp
clang/tools/libclang/CIndexUSRs.cpp
clang/tools/libclang/CXComment.cpp
clang/tools/libclang/CXCompilationDatabase.cpp
clang/tools/libclang/CXCursor.cpp
clang/tools/libclang/CXLoadedDiagnostic.cpp
clang/tools/libclang/CXSourceLocation.cpp
clang/tools/libclang/CXString.cpp
clang/tools/libclang/CXType.cpp
clang/tools/libclang/Indexing.cpp

index b597383..44a60c4 100644 (file)
@@ -32,8 +32,6 @@ struct Remap {
 // libClang public APIs.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
-
 CXRemapping clang_getRemappings(const char *migrate_dir_path) {
 #ifndef CLANG_ENABLE_ARCMT
   llvm::errs() << "error: feature not enabled in this build\n";
@@ -138,5 +136,3 @@ void clang_remap_getFilenames(CXRemapping map, unsigned index,
 void clang_remap_dispose(CXRemapping map) {
   delete static_cast<Remap *>(map);
 }
-
-} // end: extern "C"
index df61a57..7d917d6 100644 (file)
@@ -3110,7 +3110,6 @@ struct RegisterFatalErrorHandler {
 
 static llvm::ManagedStatic<RegisterFatalErrorHandler> RegisterFatalErrorHandlerOnce;
 
-extern "C" {
 CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
                           int displayDiagnostics) {
   // We use crash recovery to make some of our APIs more reliable, implicitly
@@ -3968,13 +3967,10 @@ CXCursor clang_getTranslationUnitCursor(CXTranslationUnit TU) {
   return MakeCXCursor(CXXUnit->getASTContext().getTranslationUnitDecl(), TU);
 }
 
-} // end: extern "C"
-
 //===----------------------------------------------------------------------===//
 // CXFile Operations.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
 CXString clang_getFileName(CXFile SFile) {
   if (!SFile)
     return cxstring::createNull();
@@ -4043,8 +4039,6 @@ int clang_File_isEqual(CXFile file1, CXFile file2) {
   return FEnt1->getUniqueID() == FEnt2->getUniqueID();
 }
 
-} // end: extern "C"
-
 //===----------------------------------------------------------------------===//
 // CXCursor Operations.
 //===----------------------------------------------------------------------===//
@@ -4120,8 +4114,6 @@ static SourceLocation getLocationFromExpr(const Expr *E) {
   return E->getLocStart();
 }
 
-extern "C" {
-
 unsigned clang_visitChildren(CXCursor parent,
                              CXCursorVisitor visitor,
                              CXClientData client_data) {
@@ -5383,8 +5375,6 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) {
   return cxloc::translateSourceLocation(getCursorContext(C), Loc);
 }
 
-} // end extern "C"
-
 CXCursor cxcursor::getCursor(CXTranslationUnit TU, SourceLocation SLoc) {
   assert(TU);
 
@@ -5554,8 +5544,6 @@ static SourceRange getFullCursorExtent(CXCursor C, SourceManager &SrcMgr) {
   return getRawCursorExtent(C);
 }
 
-extern "C" {
-
 CXSourceRange clang_getCursorExtent(CXCursor C) {
   SourceRange R = getRawCursorExtent(C);
   if (R.isInvalid())
@@ -6048,8 +6036,6 @@ void clang_executeOnThread(void (*fn)(void*), void *user_data,
   llvm::llvm_execute_on_thread(fn, user_data, stack_size);
 }
 
-} // end: extern "C"
-
 //===----------------------------------------------------------------------===//
 // Token-based Operations.
 //===----------------------------------------------------------------------===//
@@ -6062,8 +6048,6 @@ void clang_executeOnThread(void (*fn)(void*), void *user_data,
  *   ptr_data: for identifiers and keywords, an IdentifierInfo*.
  *   otherwise unused.
  */
-extern "C" {
-
 CXTokenKind clang_getTokenKind(CXToken CXTok) {
   return static_cast<CXTokenKind>(CXTok.int_data[0]);
 }
@@ -6252,8 +6236,6 @@ void clang_disposeTokens(CXTranslationUnit TU,
   free(Tokens);
 }
 
-} // end: extern "C"
-
 //===----------------------------------------------------------------------===//
 // Token annotation APIs.
 //===----------------------------------------------------------------------===//
@@ -6921,8 +6903,6 @@ static void clang_annotateTokensImpl(CXTranslationUnit TU, ASTUnit *CXXUnit,
   }
 }
 
-extern "C" {
-
 void clang_annotateTokens(CXTranslationUnit TU,
                           CXToken *Tokens, unsigned NumTokens,
                           CXCursor *Cursors) {
@@ -6962,13 +6942,10 @@ void clang_annotateTokens(CXTranslationUnit TU,
   }
 }
 
-} // end: extern "C"
-
 //===----------------------------------------------------------------------===//
 // Operations for querying linkage of a cursor.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
 CXLinkageKind clang_getCursorLinkage(CXCursor cursor) {
   if (!clang_isDeclaration(cursor.kind))
     return CXLinkage_Invalid;
@@ -6985,13 +6962,11 @@ CXLinkageKind clang_getCursorLinkage(CXCursor cursor) {
 
   return CXLinkage_Invalid;
 }
-} // end: extern "C"
 
 //===----------------------------------------------------------------------===//
 // Operations for querying visibility of a cursor.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
 CXVisibilityKind clang_getCursorVisibility(CXCursor cursor) {
   if (!clang_isDeclaration(cursor.kind))
     return CXVisibility_Invalid;
@@ -7006,7 +6981,6 @@ CXVisibilityKind clang_getCursorVisibility(CXCursor cursor) {
 
   return CXVisibility_Invalid;
 }
-} // end: extern "C"
 
 //===----------------------------------------------------------------------===//
 // Operations for querying language of a cursor.
@@ -7062,8 +7036,6 @@ static CXLanguageKind getDeclLanguage(const Decl *D) {
   return CXLanguage_C;
 }
 
-extern "C" {
-
 static CXAvailabilityKind getCursorAvailabilityForDecl(const Decl *D) {
   if (isa<FunctionDecl>(D) && cast<FunctionDecl>(D)->isDeleted())
     return CXAvailability_NotAvailable;
@@ -7533,14 +7505,10 @@ CXFile clang_Module_getTopLevelHeader(CXTranslationUnit TU,
   return nullptr;
 }
 
-} // end: extern "C"
-
 //===----------------------------------------------------------------------===//
 // C++ AST instrospection.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
-
 unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
     return 0;
@@ -7641,13 +7609,11 @@ unsigned clang_CXXMethod_isVirtual(CXCursor C) {
       D ? dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()) : nullptr;
   return (Method && Method->isVirtual()) ? 1 : 0;
 }
-} // end: extern "C"
 
 //===----------------------------------------------------------------------===//
 // Attribute introspection.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
 CXType clang_getIBOutletCollectionType(CXCursor C) {
   if (C.kind != CXCursor_IBOutletCollectionAttr)
     return cxtype::MakeCXType(QualType(), cxcursor::getCursorTU(C));
@@ -7657,7 +7623,6 @@ CXType clang_getIBOutletCollectionType(CXCursor C) {
   
   return cxtype::MakeCXType(A->getInterface(), cxcursor::getCursorTU(C));  
 }
-} // end: extern "C"
 
 //===----------------------------------------------------------------------===//
 // Inspecting memory usage.
@@ -7672,8 +7637,6 @@ static inline void createCXTUResourceUsageEntry(MemUsageEntries &entries,
   entries.push_back(entry);
 }
 
-extern "C" {
-
 const char *clang_getTUResourceUsageName(CXTUResourceUsageKind kind) {
   const char *str = "";
   switch (kind) {
@@ -7894,8 +7857,6 @@ void clang_disposeSourceRangeList(CXSourceRangeList *ranges) {
   }
 }
 
-} // end extern "C"
-
 void clang::PrintLibclangResourceUsage(CXTranslationUnit TU) {
   CXTUResourceUsage Usage = clang_getCXTUResourceUsage(TU);
   for (unsigned I = 0; I != Usage.numEntries; ++I)
@@ -8058,14 +8019,10 @@ cxindex::checkForMacroInMacroDefinition(const MacroInfo *MI, SourceLocation Loc,
   return checkForMacroInMacroDefinition(MI, Tok, TU);
 }
 
-extern "C" {
-
 CXString clang_getClangVersion() {
   return cxstring::createDup(getClangFullVersion());
 }
 
-} // end: extern "C"
-
 Logger &cxindex::Logger::operator<<(CXTranslationUnit TU) {
   if (TU) {
     if (ASTUnit *Unit = cxtu::getASTUnit(TU)) {
index 78e89d9..028b64a 100644 (file)
@@ -20,8 +20,6 @@
 using namespace clang;
 using namespace clang::cxcursor;
 
-extern "C" {
-
 unsigned clang_isVirtualBase(CXCursor C) {
   if (C.kind != CXCursor_CXXBaseSpecifier)
     return 0;
@@ -123,5 +121,3 @@ CXCursor clang_getSpecializedCursorTemplate(CXCursor C) {
   
   return MakeCXCursor(Template, getCursorTU(C));
 }
-  
-} // end extern "C"
index 344ed27..12895c4 100644 (file)
@@ -53,8 +53,6 @@
 using namespace clang;
 using namespace clang::cxindex;
 
-extern "C" {
-
 enum CXCompletionChunkKind
 clang_getCompletionChunkKind(CXCompletionString completion_string,
                              unsigned chunk_number) {
@@ -346,8 +344,6 @@ AllocatedCXCodeCompleteResults::~AllocatedCXCodeCompleteResults() {
     fprintf(stderr, "--- %u completion results\n",
             --CodeCompletionResultObjects);
 }
-  
-} // end extern "C"
 
 static unsigned long long getContextsForContextKind(
                                           enum CodeCompletionContext::Kind kind, 
@@ -794,7 +790,6 @@ clang_codeCompleteAt_Impl(CXTranslationUnit TU, const char *complete_filename,
   return Results;
 }
 
-extern "C" {
 CXCodeCompleteResults *clang_codeCompleteAt(CXTranslationUnit TU,
                                             const char *complete_filename,
                                             unsigned complete_line,
@@ -916,8 +911,6 @@ CXString clang_codeCompleteGetObjCSelector(CXCodeCompleteResults *ResultsIn) {
   return cxstring::createDup(Results->Selector);
 }
   
-} // end extern "C"
-
 /// \brief Simple utility function that appends a \p New string to the given
 /// \p Old string, using the \p Buffer for storage.
 ///
@@ -990,9 +983,7 @@ namespace {
   };
 }
 
-extern "C" {
-  void clang_sortCodeCompletionResults(CXCompletionResult *Results,
-                                       unsigned NumResults) {
-    std::stable_sort(Results, Results + NumResults, OrderCompletionResults());
-  }
+void clang_sortCodeCompletionResults(CXCompletionResult *Results,
+                                     unsigned NumResults) {
+  std::stable_sort(Results, Results + NumResults, OrderCompletionResults());
 }
index 18031e5..de223d3 100644 (file)
@@ -205,8 +205,6 @@ CXDiagnosticSetImpl *cxdiag::lazyCreateDiags(CXTranslationUnit TU,
 //-----------------------------------------------------------------------------
 // C Interface Routines
 //-----------------------------------------------------------------------------
-extern "C" {
-
 unsigned clang_getNumDiagnostics(CXTranslationUnit Unit) {
   if (cxtu::isNotUsableTU(Unit)) {
     LOG_BAD_TU(Unit);
@@ -477,5 +475,3 @@ unsigned clang_getNumDiagnosticsInSet(CXDiagnosticSet Diags) {
     return D->getNumDiagnostics();
   return 0;
 }
-
-} // end extern "C"
index bec0e82..b659348 100644 (file)
@@ -407,8 +407,6 @@ static bool findIncludesInFile(CXTranslationUnit TU, const FileEntry *File,
 // libclang public APIs.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
-
 CXResult clang_findReferencesInFile(CXCursor cursor, CXFile file,
                                     CXCursorAndRangeVisitor visitor) {
   LogRef Log = Logger::make(__func__);
@@ -534,5 +532,3 @@ CXResult clang_findIncludesInFileWithBlock(CXTranslationUnit TU,
   return clang_findIncludesInFile(TU, file, visitor);
 }
 
-} // end: extern "C"
-
index 5ebb5ec..4b021fc 100644 (file)
@@ -68,7 +68,6 @@ static void getInclusions(const SrcMgr::SLocEntry &(SourceManager::*Getter)(unsi
 }
 
 
-extern "C" {
 void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
                          CXClientData clientData) {
   if (cxtu::isNotUsableTU(TU)) {
@@ -96,4 +95,3 @@ void clang_getInclusions(CXTranslationUnit TU, CXInclusionVisitor CB,
     getInclusions(&SourceManager::getLocalSLocEntry, n, TU, CB, clientData);
 
 }
-} // end extern C
index 69d60c9..7cd7b6f 100644 (file)
@@ -36,8 +36,6 @@ bool cxcursor::getDeclCursorUSR(const Decl *D, SmallVectorImpl<char> &Buf) {
   return generateUSRForDecl(D, Buf);
 }
 
-extern "C" {
-
 CXString clang_getCursorUSR(CXCursor C) {
   const CXCursorKind &K = clang_getCursorKind(C);
 
@@ -140,5 +138,3 @@ CXString clang_constructUSR_ObjCProperty(const char *property,
   generateUSRForObjCProperty(property, /*isClassProp=*/false, OS);
   return cxstring::createDup(OS.str());
 }
-
-} // end extern "C"
index c02eea9..028fdf1 100644 (file)
@@ -26,8 +26,6 @@ using namespace clang;
 using namespace clang::comments;
 using namespace clang::cxcomment;
 
-extern "C" {
-
 CXComment clang_Cursor_getParsedComment(CXCursor C) {
   using namespace clang::cxcursor;
 
@@ -406,5 +404,3 @@ CXString clang_FullComment_getAsXML(CXComment CXC) {
   return cxstring::createDup(XML.str());
 }
 
-} // end extern "C"
-
index 82498bf..c122ec8 100644 (file)
@@ -6,8 +6,6 @@
 using namespace clang;
 using namespace clang::tooling;
 
-extern "C" {
-
 // FIXME: do something more useful with the error message
 CXCompilationDatabase
 clang_CompilationDatabase_fromDirectory(const char *BuildDir,
@@ -180,5 +178,3 @@ clang_CompileCommand_getMappedSourceContent(CXCompileCommand CCmd, unsigned I)
 
   return cxstring::createRef(Cmd->MappedSources[I].second.c_str());
 }
-
-} // end: extern "C"
index 7f0a297..06b0aa9 100644 (file)
@@ -1104,8 +1104,6 @@ bool cxcursor::isFirstInDeclGroup(CXCursor C) {
 // libclang CXCursor APIs
 //===----------------------------------------------------------------------===//
 
-extern "C" {
-
 int clang_Cursor_isNull(CXCursor cursor) {
   return clang_equalCursors(cursor, clang_getNullCursor());
 }
@@ -1295,8 +1293,6 @@ unsigned long long clang_Cursor_getTemplateArgumentUnsignedValue(CXCursor C,
   return TA.getAsIntegral().getZExtValue();
 }
 
-} // end: extern "C"
-
 //===----------------------------------------------------------------------===//
 // CXCursorSet.
 //===----------------------------------------------------------------------===//
@@ -1330,7 +1326,6 @@ public:
 };
 }
 
-extern "C" {
 CXCursorSet clang_createCXCursorSet() {
   return packCXCursorSet(new CXCursorSet_Impl());
 }
@@ -1393,7 +1388,6 @@ CXCompletionString clang_getCursorCompletionString(CXCursor cursor) {
   }
   return nullptr;
 }
-} // end: extern C.
 
 namespace {
   struct OverridenCursorsPool {
@@ -1418,7 +1412,6 @@ void cxcursor::disposeOverridenCXCursorsPool(void *pool) {
   delete static_cast<OverridenCursorsPool*>(pool);
 }
  
-extern "C" {
 void clang_getOverriddenCursors(CXCursor cursor,
                                 CXCursor **overridden,
                                 unsigned *num_overridden) {
@@ -1540,5 +1533,3 @@ CXType clang_Cursor_getReceiverType(CXCursor C) {
 
   return cxtype::MakeCXType(QualType(), TU);
 }
-
-} // end: extern "C"
index c866717..36c3dca 100644 (file)
@@ -387,11 +387,9 @@ std::error_code DiagLoader::visitDiagnosticRecord(
   return std::error_code();
 }
 
-extern "C" {
 CXDiagnosticSet clang_loadDiagnostics(const char *file,
                                       enum CXLoadDiag_Error *error,
                                       CXString *errorString) {
   DiagLoader L(error, errorString);
   return L.load(file);
 }
-} // end extern 'C'.
index 68ecf38..2e0ea4e 100644 (file)
@@ -38,8 +38,6 @@ static bool isASTUnitSourceLocation(const CXSourceLocation &L) {
 // Basic construction and comparison of CXSourceLocations and CXSourceRanges.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
-  
 CXSourceLocation clang_getNullLocation() {
   CXSourceLocation Result = { { nullptr, nullptr }, 0 };
   return Result;
@@ -110,14 +108,10 @@ CXSourceLocation clang_getRangeEnd(CXSourceRange range) {
   return Result;
 }
 
-} // end extern "C"
-
 //===----------------------------------------------------------------------===//
 //  Getting CXSourceLocations and CXSourceRanges from a translation unit.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
-  
 CXSourceLocation clang_getLocation(CXTranslationUnit TU,
                                    CXFile file,
                                    unsigned line,
@@ -174,8 +168,6 @@ CXSourceLocation clang_getLocationForOffset(CXTranslationUnit TU,
   return cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
 }
 
-} // end extern "C"
-
 //===----------------------------------------------------------------------===//
 // Routines for expanding and manipulating CXSourceLocations, regardless
 // of their origin.
@@ -205,8 +197,6 @@ static void createNullLocation(CXString *filename, unsigned *line,
     *offset = 0;
 }
 
-extern "C" {
-
 int clang_Location_isInSystemHeader(CXSourceLocation location) {
   const SourceLocation Loc =
     SourceLocation::getFromRawEncoding(location.int_data);
@@ -382,5 +372,3 @@ void clang_getFileLocation(CXSourceLocation location,
   if (offset)
     *offset = FileOffset;
 }
-
-} // end extern "C"
index 2148181..4486031 100644 (file)
@@ -161,7 +161,6 @@ bool isManagedByPool(CXString str) {
 // libClang public APIs.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
 const char *clang_getCString(CXString string) {
   if (string.private_flags == (unsigned) CXS_StringBuf) {
     return static_cast<const cxstring::CXStringBuf *>(string.data)->Data.data();
@@ -191,5 +190,3 @@ void clang_disposeStringSet(CXStringSet *set) {
   delete set;
 }
 
-} // end: extern "C"
-
index 475b40f..66caf34 100644 (file)
@@ -182,8 +182,6 @@ FindTemplateArgumentTypeAt(ArrayRef<TemplateArgument> TA, unsigned index) {
   return None;
 }
 
-extern "C" {
-
 CXType clang_getCursorType(CXCursor C) {
   using namespace cxcursor;
 
@@ -1038,5 +1036,3 @@ CXType clang_Type_getNamedType(CXType CT){
 
   return MakeCXType(QualType(), GetTU(CT));
 }
-
-} // end: extern "C"
index 878d75e..c18b540 100644 (file)
@@ -687,8 +687,6 @@ static CXErrorCode clang_indexTranslationUnit_Impl(
 // libclang public APIs.
 //===----------------------------------------------------------------------===//
 
-extern "C" {
-
 int clang_index_isEntityObjCContainerKind(CXIdxEntityKind K) {
   return CXIdxEntity_ObjCClass <= K && K <= CXIdxEntity_ObjCCategory;
 }
@@ -978,5 +976,3 @@ CXSourceLocation clang_indexLoc_getCXSourceLocation(CXIdxLoc location) {
   return cxloc::translateSourceLocation(DataConsumer.getASTContext(), Loc);
 }
 
-} // end: extern "C"
-