[LLVMdev] Patch to determine whether an LLVM archive file really is such
Reid Spencer
reid at x10sys.com
Sat Feb 26 14:01:31 PST 2005
Adam,
Patch looks great and is committed.
Thanks!
Reid.
On Sat, 2005-02-26 at 12:18, Adam Treat wrote:
> This is needed for my native linker patch that is coming soon.
>
> As discussed on IRC:
>
> Index: lib/Bytecode/Archive/ArchiveReader.cpp
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/lib/Bytecode/Archive/ArchiveReader.cpp,v
> retrieving revision 1.38
> diff -u -r1.38 ArchiveReader.cpp
> --- lib/Bytecode/Archive/ArchiveReader.cpp 29 Dec 2004 01:20:24 -0000
> 1.38
> +++ lib/Bytecode/Archive/ArchiveReader.cpp 26 Feb 2005 20:05:12 -0000
> @@ -503,3 +503,32 @@
> }
> }
> }
> +
> +bool
> +Archive::isBytecodeArchive()
> +{
> + //Make sure the symTab has been loaded...
> + //in most cases this should have been done
> + //when the archive was constructed, but still,
> + //this is just in case.
> + if ( !symTab.size() )
> + loadSymbolTable();
> +
> + //Now that we know it's been loaded, return true
> + //if it has a size
> + if ( symTab.size() ) return true;
> +
> + //We still can't be sure it isn't a bytecode archive
> + loadArchive();
> +
> + std::vector<Module *> Modules;
> + std::string ErrorMessage;
> +
> + //If getAllModules gives an error then this isn't a proper
> + //bytecode archive
> + if ( getAllModules( Modules, &ErrorMessage ) ) return false;
> +
> + //Finally, if we find any bytecode modules then this is a proper
> + //bytecode archive
> + return Modules.size();
> +}
> Index: include/llvm/Bytecode/Archive.h
> ===================================================================
> RCS file: /var/cvs/llvm/llvm/include/llvm/Bytecode/Archive.h,v
> retrieving revision 1.9
> diff -u -r1.9 Archive.h
> --- include/llvm/Bytecode/Archive.h 13 Dec 2004 02:58:16 -0000 1.9
> +++ include/llvm/Bytecode/Archive.h 26 Feb 2005 20:05:13 -0000
> @@ -414,6 +414,15 @@
> std::set<std::string>& symbols, ///< Symbols to be sought
> std::set<ModuleProvider*>& modules ///< The modules matching \p
> symbols
> );
> +
> + /// This method determines whether the archive is a properly formed llvm
> + /// bytecode archive. It first makes sure the symbol table has been
> loaded
> + /// and has a non-zero size. If it does, then it is an archive. If not,
> + /// then it tries to load all the bytecode modules of the archive.
> Finally,
> + /// it returns whether it was successfull.
> + /// @returns true if the archive is a proper llvm bytecode archive
> + /// @brief Determine whether the archive is a proper llvm bytecode
> archive.
> + bool isBytecodeArchive();
>
> /// @}
> /// @name Mutators
>
> ______________________________________________________________________
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050226/0d8569c2/attachment.sig>
More information about the llvm-dev
mailing list