Jordan Rose [Fri, 10 Jan 2014 20:06:06 +0000 (20:06 +0000)]
[analyzer] Model getters of known-@synthesized Objective-C properties.
...by synthesizing their body to be "return self->_prop;", with an extra
nudge to RetainCountChecker to still treat the value as +0 if we have no
other information.
This doesn't handle weak properties, but that's mostly correct anyway,
since they can go to nil at any time. This also doesn't apply to properties
whose implementations we can't see, since they may not be backed by an
ivar at all. And finally, this doesn't handle properties of C++ class type,
because we can't invoke the copy constructor. (Sema has actually done this
work already, but the AST it synthesizes is one the analyzer doesn't quite
handle -- it has an rvalue DeclRefExpr.)
Modeling setters is likely to be more difficult (since it requires
handling strong/copy), but not impossible.
ObjectiveC. Remove warning on mismatched methods
which may belong to unrelated classes. It was
primarily intended for miuse of @selector expression.
But warning is too noisy and will be issued when
an actual @selector is used. // rdar://15740134
Alp Toker [Fri, 10 Jan 2014 14:37:02 +0000 (14:37 +0000)]
Remove unexpected code completion handling from ConsumeToken()
With this change tok::code_completion is finally handled exclusively as a
special token kind like other tokens that need special treatment.
All callers have been updated to use the specific token consumption methods and
the parser has a clear idea the current token isn't special by the time
ConsumeToken() gets called, so this has been unreachable for some time.
ConsumeAnyToken() behaviour is unchanged and will continue to support
unexpected code completion as part of the special token path.
This survived an amount of fuzzing and validation, but please ping the list if
you hit a code path that previously relied on the old unexpected handler and
now asserts.
Alp Toker [Fri, 10 Jan 2014 11:19:45 +0000 (11:19 +0000)]
Update LangOpt descriptions
Based on recent discussions, attempt to provide a clearer distinction between
MicrosoftMode and MicrosoftExt. This still doesn't feel perfect but gives a
better idea which is which.
Also update the CPlusPlus11 description which got missed in r171367.
reapply r198858: Disable LeakSanitizer in TableGen binaries, see PR18325; this time LeakSanitizerIsTurnedOffForTheCurrentProcess is used instead of __lsan_is_turned_off
Richard Trieu [Fri, 10 Jan 2014 04:38:09 +0000 (04:38 +0000)]
Make the tautological out of range warning use Sema::DiagRuntimeBehavior so that
the warning will not trigger on code protected by compile time checks.
Warren Hunt [Fri, 10 Jan 2014 01:28:05 +0000 (01:28 +0000)]
[ms-abi] Handle __declspec(align) on bitfields "properly"
__declspec(align), when applied to bitfields affects their perferred
alignment instead of their required alignment. We don't know why.
Also, #pragma pack(n) turns packing *off* if n is greater than the
pointer size. This is now observable because of the impact of
declspec(align) on bitfields.
ObjectiveC. 1) Warn when @dynamic (as well as synthesize)
property has the naming convention that implies 'ownership'.
2) improve on diagnostic and make it property specific.
3) fix the line number in the case of default property
synthesis. // rdar://15757510
Warren Hunt [Thu, 9 Jan 2014 23:51:31 +0000 (23:51 +0000)]
[ms-abi] Fixing CGRecordLayoutBuilder w.r.t. MS NonVirutalBase Layout
The MS abi lays out *all* non-virtual bases with leading vfptrs before
laying out non-virutal bases without vfptrs. This guarantees that the
primary base is laid out first. r198818 fixed RecordLayoutBuilder to
produce compatiable layouts. This patch fixes CGRecordLayoutBuilder to
be able to consume those layouts and produce meaningful output without
tripping any asserts about assumed incoming layout.
A test case is included that shows CGRecordLayoutBuilder in fact
produces output in the compatiable order.
Aaron Ballman [Thu, 9 Jan 2014 22:57:44 +0000 (22:57 +0000)]
__has_attribute now understands target-specific attributes. So when you ask whether an ARM target has the "interrupt" attribute, it will return true for ARM and MSP430 targets, and false for others.
Aaron Ballman [Thu, 9 Jan 2014 22:48:32 +0000 (22:48 +0000)]
Removing the notion of TargetAttributesSema and replacing it with one where the parsed attributes are responsible for knowing their target-specific nature, instead of letting Sema figure it out. This is necessary so that __has_attribute can eventually determine whether a parsed attribute applies to the given target or not.
Ben Langmuir [Thu, 9 Jan 2014 20:53:49 +0000 (20:53 +0000)]
Preserve -fretain-comments-from-system-headers in modules
Preserves the setting of -fretain-comments-from-system-headers when
building/saving/loading module files. This allows code completion to pick up
documentation comments from system modules.
In ARC, __attribute__((objc_precise_lifetime)) guarantees that the
object stored in it will survive to the end of the variable's formal
lifetime. It is therefore useful even if it completely unused.
Alp Toker [Thu, 9 Jan 2014 19:43:17 +0000 (19:43 +0000)]
Revert "Disable LeakSanitizer in TableGen binaries, see PR18325"
To declare or define reserved identifers is undefined behaviour in standard
C++. This needs to be addressed in compiler-rt before it can be used in LLVM.
Aaron Ballman [Thu, 9 Jan 2014 19:39:35 +0000 (19:39 +0000)]
Removing a bit of custom parsing functionality used by the thread safety analysis APIs. Now using tablegen to determine whether an attribute's arguments should be parsed in an unevaluated context instead of relying on a separate, hard-coded list of attributes.
Daniel Jasper [Thu, 9 Jan 2014 14:18:12 +0000 (14:18 +0000)]
clang-format: Add @s when breaking NSString literals.
While it is allowed to not have an @ on subsequent lines, it seems
general practice to add them. If undesired, the code author can easily
remove them again and clang-format won't re-add them.
Daniel Jasper [Thu, 9 Jan 2014 13:56:49 +0000 (13:56 +0000)]
clang-format: Understand #pragma mark
Before:
#pragma mark Any non - hyphenated or hyphenated string(including parentheses).
After:
#pragma mark Any non-hyphenated or hyphenated string (including parentheses).
Daniel Jasper [Thu, 9 Jan 2014 13:42:56 +0000 (13:42 +0000)]
clang-format: Some tweaks to braces list formatting:
- Format a braced list with one element per line if it has nested
braced lists.
- Use a column layout only when the list has 6+ elements (instead of the
current 4+ elements).
The OpenCL specification states that images are allocated
from the global address space (6.5.1 of the OpenCL 1.2 specification).
This makes clang construct the image arguments in the global address
space and generate the argument metadata with the correct address space
descriptor.
Update Clang's CFGBlock interface to conform to the strange part of
LLVM's Value interface which is used in LLVM's DominatorTree analysis
and which changed in LLVM r198836.
The DominatorTree analysis is actually a generic graph analysis and
should be moved to LLVM's support library to clarify that Clang and
others are using it with arbitrary graphs. Further, it seems likely that
it should be using something other than printAsOperand, but this is
a simpler build fix. I'll clean this up later.
Richard Smith [Thu, 9 Jan 2014 02:22:22 +0000 (02:22 +0000)]
PR18401: Fix assert by implementing the current proposed direction of core
issue 1430. Don't allow a pack expansion to be used as an argument to an alias
template unless the corresponding parameter is a parameter pack.
Warren Hunt [Thu, 9 Jan 2014 00:30:56 +0000 (00:30 +0000)]
[ms-abi] Refactor Microsoft Record Layout
This patch refactors microsoft record layout to be more "natural". The
most dominant change is that vbptrs and vfptrs are injected after the
fact. This simplifies the implementation and the math for the offest
for the first base/field after the vbptr.
Alp Toker [Thu, 9 Jan 2014 00:13:52 +0000 (00:13 +0000)]
Implement isCXX11FinalKeyword() in terms of isCXX11VirtSpecifier()
It's not worth keeping two copies of the identifier init and comparison code
just to save a pointer coparison.
This should reduce further once we get proper contextual keywords in the token
stream, so having the identifier checks in one place is a step towards that.
Alp Toker [Wed, 8 Jan 2014 20:06:24 +0000 (20:06 +0000)]
Ensure that ENABLE_SHARED is substituted for use in Windows builds
We (perhaps over-cautiously) disable the new plugin tests on static Windows
builds right now, matching what LLVM core does. This change was needed for the
lit check to work.
Jordan Rose [Wed, 8 Jan 2014 18:46:55 +0000 (18:46 +0000)]
[analyzer] Warn about double-delete in C++ at the second delete...
...rather somewhere in the destructor when we try to access something and
realize the object has already been deleted. This is necessary because
the destructor is processed before the 'delete' itself.
Alp Toker [Wed, 8 Jan 2014 11:55:49 +0000 (11:55 +0000)]
Build fix following r198747
Convert CMake CLANG_BUILD_EXAMPLES to a boolean value for consumption by
Python, otherwise the raw config string gets passed through which may not be
0/1.
The if/else matches the technique used to solve the problem in LLVM's own
CMakeLists.txt.
Alp Toker [Wed, 8 Jan 2014 11:38:47 +0000 (11:38 +0000)]
Add tests for clang plugins
Somehow the entire plugin infrastructure went wholly untested until now.
The only plugins available for use in testing are the examples, so plugin tests
will only be run if CLANG_BUILD_EXAMPLES is enabled in the build.
(The examples should really be enabled by default, not just to aid testing but
also to prevent bitrot in some key user-facing code. I'll propose that
shortly.)
Richard Smith [Wed, 8 Jan 2014 00:56:48 +0000 (00:56 +0000)]
PR18234: Mark a tag definition as invalid early if it appears in a
type-specifier in C++. Some checks will assert in this case otherwise (in
particular, the access specifier may be missing if this happens inside a class
definition, due to a violation of an AST invariant).
Adrian Prantl [Tue, 7 Jan 2014 22:05:55 +0000 (22:05 +0000)]
Re-applying r198699 after reverting r198461.
Debug info: Implement a cleaner version of r198461. For symmetry with
C and C++ don't emit an extra lexical scope for the compound statement
that is the body of an Objective-C method.
Jordan Rose [Tue, 7 Jan 2014 21:39:48 +0000 (21:39 +0000)]
[analyzer] Pointers escape into +[NSValue valueWithPointer:]...
...even though the argument is declared "const void *", because this is
just a way to pass pointers around as objects. (Though NSData is often
a better one.)
RetainCountChecker has to track returned object values to know if they are
retained or not. Under ARC, even methods that return +1 are tracked by the
system and should be treated as +0. However, this effect behaves exactly
like NotOwned(ObjC), i.e. a generic Objective-C method that actually returns
+0, so we don't need a special case for it.
Nico Weber [Tue, 7 Jan 2014 20:10:39 +0000 (20:10 +0000)]
[cmake] Write Version.inc at cmake time, not at build time.
In SVN checkouts, clang_revision_tag is rerun on every build, even if nothing
else is dirty. After this change, Version.inc is only written at cmake time,
so that empty builds run 0 build steps (like r191784 apparently did for git).
Adrian Prantl [Tue, 7 Jan 2014 19:24:24 +0000 (19:24 +0000)]
Debug info: Implement a cleaner version of r198461. For symmetry with
C and C++ don't emit an extra lexical scope for the compound statement
that is the body of an Objective-C method.
Sort all the #include lines with LLVM's utils/sort_includes.py which
encodes the canonical rules for LLVM's style. I noticed this had drifted
quite a bit when cleaning up LLVM, so wanted to clean up Clang as well.
For areVectorOperandsLaxBitCastable(), only return false if both opearands are vector types
and add a diagnostic when the operand is a vector and non-scalar value.
Alp Toker [Tue, 7 Jan 2014 02:35:33 +0000 (02:35 +0000)]
Bring back magic constants in the digraph diagnostic
This backs out changes in commit r198605 and part of r198604, replacing the
original tok::kw_template with a slightly more obvious placeholder
tok::unknown.
Adrian Prantl [Tue, 7 Jan 2014 01:19:08 +0000 (01:19 +0000)]
Implement a new -fstandalone-debug option. rdar://problem/15685848
It controls everything that -flimit-debug-info used to, plus the
vtable type optimization. The old -fno-limit-debug-info option is now an
alias to -fstandalone-debug and vice versa.
Standalone is the default on Darwin until dtrace is updated to work with
non-standalone debug info (rdar://problem/15758808).
Note: I kept the LimitedDebugInfo name in CodeGenOptions::DebugInfoKind
because NoStandaloneDebugInfo sounded even more confusing.
Alp Toker [Mon, 6 Jan 2014 12:54:18 +0000 (12:54 +0000)]
Support diagnostic formatting of keyword tokens
Implemented with a new getKeywordSpelling() accessor. Unlike getTokenName() the
result of this function is stable and may be used in diagnostic output.
Uses of this feature are split out into the subsequent commit.