clang::CodeGen::CodeGenModule::GetOrCreateLLVMGlobal

Hi,
   I noticed that CodeGenModule.cpp (around line number 1514):

     if (UnnamedAddr)
       Entry->setUnnamedAddr(true);

is executed only in the 'Get'-branch. I.e if the global doesn't exist this flag is not taken into account. Is that an inconsistency or a desired behavior?
Many thanks,
Vassil

bccing cfe-dev, moving the cfe-commits

Hi,
  I noticed that CodeGenModule.cpp (around line number 1514):

    if (UnnamedAddr)
      Entry->setUnnamedAddr(true);

is executed only in the 'Get'-branch. I.e if the global doesn't exist this
flag is not taken into account. Is that an inconsistency or a desired
behavior?

That is a bug, thanks!

For

struct Foo {
  ~Foo();
};
Foo x;

We will output "@__dso_handle = external global i8", but an
unnamed_addr gets added if a second "Foo y" is added.

John (or Fariborz), can you check if the attached patch is doing the
correct thing for obj-c?

Thanks,
Rafael

t.patch (1.81 KB)