[cfe-commits] r172565 - /cfe/trunk/tools/libclang/IndexingContext.cpp

David Greene greened at obbligato.org
Tue Jan 15 14:09:51 PST 2013


Author: greened
Date: Tue Jan 15 16:09:51 2013
New Revision: 172565

URL: http://llvm.org/viewvc/llvm-project?rev=172565&view=rev
Log:
Fix Casting

Use const_cast<> to avoid a cast-away-const error.

Modified:
    cfe/trunk/tools/libclang/IndexingContext.cpp

Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=172565&r1=172564&r2=172565&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Tue Jan 15 16:09:51 2013
@@ -231,7 +231,9 @@
 
 void IndexingContext::enteredMainFile(const FileEntry *File) {
   if (File && CB.enteredMainFile) {
-    CXIdxClientFile idxFile = CB.enteredMainFile(ClientData, (CXFile)File, 0);
+    CXIdxClientFile idxFile =
+      CB.enteredMainFile(ClientData,
+                         static_cast<CXFile>(const_cast<FileEntry *>(File)), 0);
     FileMap[File] = idxFile;
   }
 }
@@ -247,7 +249,8 @@
   ScratchAlloc SA(*this);
   CXIdxIncludedFileInfo Info = { getIndexLoc(hashLoc),
                                  SA.toCStr(filename),
-                                 (CXFile)File,
+                                 static_cast<CXFile>(
+                                   const_cast<FileEntry *>(File)),
                                  isImport, isAngled, isModuleImport };
   CXIdxClientFile idxFile = CB.ppIncludedFile(ClientData, &Info);
   FileMap[File] = idxFile;
@@ -263,7 +266,8 @@
   std::string ModuleName = Mod->getFullModuleName();
 
   CXIdxImportedASTFileInfo Info = {
-                                    (CXFile)Mod->getASTFile(),
+                                    static_cast<CXFile>(
+                                    const_cast<FileEntry *>(Mod->getASTFile())),
                                     Mod,
                                     getIndexLoc(ImportD->getLocation()),
                                     ImportD->isImplicit()
@@ -277,7 +281,8 @@
     return;
 
   CXIdxImportedASTFileInfo Info = {
-                                    (CXFile)File,
+                                    static_cast<CXFile>(
+                                      const_cast<FileEntry *>(File)),
                                     /*module=*/NULL,
                                     getIndexLoc(SourceLocation()),
                                     /*isImplicit=*/false
@@ -862,7 +867,7 @@
   if (Loc.isInvalid())
     return idxLoc;
 
-  idxLoc.ptr_data[0] = (void*)this;
+  idxLoc.ptr_data[0] = const_cast<IndexingContext *>(this);
   idxLoc.int_data = Loc.getRawEncoding();
   return idxLoc;
 }
@@ -888,7 +893,7 @@
   if (indexFile)
     *indexFile = getIndexFile(FE);
   if (file)
-    *file = (void *)FE;
+    *file = const_cast<FileEntry *>(FE);
   if (line)
     *line = SM.getLineNumber(FID, FileOffset);
   if (column)





More information about the cfe-commits mailing list