[LLVMdev] [lld] Handling a whole bunch of readers

Rui Ueyama ruiu at google.com
Wed Oct 9 12:14:56 PDT 2013


On Wed, Oct 9, 2013 at 11:42 AM, Shankar Easwaran
<shankare at codeaurora.org>wrote:

> All files cannot be identified with a magic though. For example Linker
> scripts, and currently YAML files.


You could do whatever to identify the file type. identify_magic() is one
way, checking the file extension is another. My point is that map-based
approach would be simpler than isMyFormat() approach.

On 10/9/2013 1:36 PM, Rui Ueyama wrote:
>
>> I guess in each isMyFormat(), you would check the given file's magic using
>> llvm::sys::fs::identify_magic(**), and then check if it's a known value
>> for
>> that reader. That would be repeated in each isMyFormat(), which is not
>> very
>> good.
>>
>> I'd do that using a mapping from file magic to reader. I mean, we could
>> call identify_magic() at some central place, look up the mapping, and then
>> dispatch.
>>
>> On Wed, Oct 9, 2013 at 11:23 AM, Shankar Easwaran
>> <shankare at codeaurora.org>**wrote:
>>
>>  Hi,
>>>
>>> We have a whole bunch of readers(we would have some more too), and was
>>> thinking if we should have a vector of Readers, and have a function
>>> isMyFormat in each of them.
>>>
>>> Any reader that knows to handle, goes ahead and parses the file.
>>>
>>> On a side note, we currently use .objtxt as an figure out if the file is
>>> a
>>> YAML file or not. I have added FIXME's in the code, if we could some kind
>>> of magic (or) a better way to figure out if the file is YAML ?
>>>
>>> Thanks
>>>
>>> Shankar Easwaran
>>>
>>> --
>>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
>>> by the Linux Foundation
>>>
>>> ______________________________****_________________
>>>
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/****mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev>
>>> <http:**//lists.cs.uiuc.edu/mailman/**listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
>>> >
>>>
>>>
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted
> by the Linux Foundation
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131009/2b002f1b/attachment.html>


More information about the llvm-dev mailing list