Skip to content

Correction for 32 bits platforms #6845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/ClangImporter/SwiftLookupTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Support/Compiler.h"
#include <functional>
#include <utility>

Expand Down Expand Up @@ -133,8 +134,14 @@ class EffectiveClangContext {
return StringRef(Unresolved.Data, UnresolvedLength);
}
};

#if LLVM_PTR_SIZE == 4
static_assert(sizeof(EffectiveClangContext) <= 4 * sizeof(void *),
"should fit in four pointers");
#else
static_assert(sizeof(EffectiveClangContext) <= 2 * sizeof(void *),
"should fit in a couple pointers");
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can do something more generic considering that LLVM_PTR_SIZE is equal to sizeof(void *) and we know that EffectiveClangContext should be less than or equal to 16 bytes long. Otherwise, LGTM. Nice catch!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldn't even bother. @milseman?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Originally I think the whole thing fit in one pointer, even on 32-bit platforms. Going from one to two is a bigger jump than two to four.)


class SwiftLookupTableReader;
class SwiftLookupTableWriter;
Expand Down