Skip to content

Commit b2eafa4

Browse files
committed
[Clang importer] Fix a use-after-free in enum info caching.
Also, make the cache kick in between when a module is built and when it is used. This isn't actually an important case, but it makes it a whole lot more common to actually see the use-after-free break things. Fixes rdar://problem/24869070.
1 parent 1ea2d46 commit b2eafa4

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/ClangImporter/ImportEnumInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class EnumInfo {
6060

6161
/// The enum's common constant name prefix, which will be stripped from
6262
/// constants
63-
StringRef constantNamePrefix = StringRef();
63+
std::string constantNamePrefix = StringRef();
6464

6565
/// The identifying attribute for specially imported enums
6666
///

lib/ClangImporter/ImporterImpl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
473473
if (*moduleOpt)
474474
moduleName = (*moduleOpt)->getTopLevelModuleName();
475475
}
476+
if (moduleName.empty())
477+
moduleName = decl->getASTContext().getLangOpts().CurrentModule;
476478

477479
StringRef enumName =
478480
decl->getDeclName() ? decl->getName()

0 commit comments

Comments
 (0)