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

Shankar Easwaran shankare at codeaurora.org
Wed Oct 9 11:42:03 PDT 2013


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

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>
>>


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation




More information about the llvm-dev mailing list