[lld] r262813 - Split BitcodeFile::parse. NFC.

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 13:05:59 PST 2016


On Mon, Mar 7, 2016 at 1:01 PM, Rui Ueyama <ruiu at google.com> wrote:

> The tricky part is that the return value of getVisibility is not a enum
> value but just a small integer such as uint8_t. So I was not sure if it
> covered all possible cases.
>

The warnings are about the set of cases in the switch. The return value
shouldn't matter.

-- Sean Silva


>
> On Mon, Mar 7, 2016 at 12:49 PM, Sean Silva <chisophugis at gmail.com> wrote:
>
>>
>>
>> On Mon, Mar 7, 2016 at 11:09 AM, Rui Ueyama via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> On Mon, Mar 7, 2016 at 7:36 AM, Rafael EspĂ­ndola <
>>> rafael.espindola at gmail.com> wrote:
>>>
>>>> This is a nice change in general, but why convert from
>>>> GlobalValue::DefaultVisibility to default? We had a fully covered
>>>> switch before.
>>>>
>>>
>>> That's what I was not sure, so I was thinking that that could cause a
>>> "function does not return a value" warning. I will revert that part.
>>>
>>
>> We have guidance about that here:
>> http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations
>>
>> -- Sean Silva
>>
>>
>>>
>>>
>>>> Cheers,
>>>> Rafael
>>>>
>>>>
>>>> On 6 March 2016 at 19:54, Rui Ueyama via llvm-commits
>>>> <llvm-commits at lists.llvm.org> wrote:
>>>> > Author: ruiu
>>>> > Date: Sun Mar  6 18:54:17 2016
>>>> > New Revision: 262813
>>>> >
>>>> > URL: http://llvm.org/viewvc/llvm-project?rev=262813&view=rev
>>>> > Log:
>>>> > Split BitcodeFile::parse. NFC.
>>>> >
>>>> > Modified:
>>>> >     lld/trunk/ELF/InputFiles.cpp
>>>> >
>>>> > Modified: lld/trunk/ELF/InputFiles.cpp
>>>> > URL:
>>>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=262813&r1=262812&r2=262813&view=diff
>>>> >
>>>> ==============================================================================
>>>> > --- lld/trunk/ELF/InputFiles.cpp (original)
>>>> > +++ lld/trunk/ELF/InputFiles.cpp Sun Mar  6 18:54:17 2016
>>>> > @@ -414,6 +414,17 @@ bool BitcodeFile::classof(const InputFil
>>>> >    return F->kind() == BitcodeKind;
>>>> >  }
>>>> >
>>>> > +static uint8_t getGvVisibility(const GlobalValue *GV) {
>>>> > +  switch (GV->getVisibility()) {
>>>> > +  case GlobalValue::HiddenVisibility:
>>>> > +    return STV_HIDDEN;
>>>> > +  case GlobalValue::ProtectedVisibility:
>>>> > +    return STV_PROTECTED;
>>>> > +  default:
>>>> > +    return STV_DEFAULT;
>>>> > +  }
>>>> > +}
>>>> > +
>>>> >  void BitcodeFile::parse(DenseSet<StringRef> &ComdatGroups) {
>>>> >    LLVMContext Context;
>>>> >    std::unique_ptr<IRObjectFile> Obj = check(IRObjectFile::create(MB,
>>>> Context));
>>>> > @@ -432,23 +443,14 @@ void BitcodeFile::parse(DenseSet<StringR
>>>> >        if (const Comdat *C = GV->getComdat())
>>>> >          if (!KeptComdats.count(C))
>>>> >            continue;
>>>> > -      switch (GV->getVisibility()) {
>>>> > -      case GlobalValue::DefaultVisibility:
>>>> > -        Visibility = STV_DEFAULT;
>>>> > -        break;
>>>> > -      case GlobalValue::HiddenVisibility:
>>>> > -        Visibility = STV_HIDDEN;
>>>> > -        break;
>>>> > -      case GlobalValue::ProtectedVisibility:
>>>> > -        Visibility = STV_PROTECTED;
>>>> > -        break;
>>>> > -      }
>>>> > +      Visibility = getGvVisibility(GV);
>>>> >      }
>>>> >
>>>> >      SmallString<64> Name;
>>>> >      raw_svector_ostream OS(Name);
>>>> >      Sym.printName(OS);
>>>> >      StringRef NameRef = Saver.save(StringRef(Name));
>>>> > +
>>>> >      SymbolBody *Body;
>>>> >      uint32_t Flags = Sym.getFlags();
>>>> >      bool IsWeak = Flags & BasicSymbolRef::SF_Weak;
>>>> >
>>>> >
>>>> > _______________________________________________
>>>> > llvm-commits mailing list
>>>> > llvm-commits at lists.llvm.org
>>>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>>
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160307/dc5d4fab/attachment.html>


More information about the llvm-commits mailing list