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.
Alp Toker [Sun, 5 Jan 2014 06:38:18 +0000 (06:38 +0000)]
Pre-declare '::type_info' in MicrosoftMode only, not MicrosoftExt
It was previously enabled in both but should only have been part of the drop-in
quirks mode that is 'MicrosoftMode' given that it's only useful for
compatibility with the Microsoft headers/runtime.
Alp Toker [Sun, 5 Jan 2014 04:17:27 +0000 (04:17 +0000)]
Tweak the parse recovery in r198540
Cover a hypothetical case when we might not have reached the final argument
declaration for some reason during recovery, and split out for readability.
Alp Toker [Sun, 5 Jan 2014 03:27:57 +0000 (03:27 +0000)]
Fix bungled parse recovery in K&R function declarations
void knrNoSemi(i) int i { }
Adherents of The C Programming Language unfortunate enough to miss a semicolon
as above would be met with a cascade of errors spanning the remainder of the
TU.
This patch introduces a beautiful parse error recovery, complete with helpful
FixIt to restore sanity.
Before (output redacted for brevity):
error: 'error' diagnostics seen but not expected:
File declarators.c Line 119: declaration does not declare a parameter
File declarators.c Line 123: declaration does not declare a parameter
File declarators.c Line 127: parameter named 'func_E12' is missing
File declarators.c Line 127: expected ';' at end of declaration
File declarators.c Line 133: parameter named 'func_E13' is missing
File declarators.c Line 133: expected ';' at end of declaration
File declarators.c Line 139: parameter named 'func_E14' is missing
File declarators.c Line 139: expected ';' at end of declaration
File declarators.c Line 145: parameter named 'func_E15' is missing
File declarators.c Line 145: expected ';' at end of declaration
File declarators.c Line 150: expected function body after function declarator
File declarators.c Line 119: declaration of 'enum E11' will not be visible outside of this function
File declarators.c Line 123: declaration of 'enum E12' will not be visible outside of this function
File declarators.c Line 133: ISO C forbids forward references to 'enum' types
File declarators.c Line 133: declaration of 'enum E13' will not be visible outside of this function
File declarators.c Line 139: ISO C forbids forward references to 'enum' types
File declarators.c Line 139: declaration of 'enum E14' will not be visible outside of this function
File declarators.c Line 145: ISO C forbids forward references to 'enum' types
File declarators.c Line 145: declaration of 'enum E15' will not be visible outside of this function
...
After:
declarators.c:103:24: error: expected ';' at end of declaration
void knrNoSemi(i) int i { }
^
;
Patch found in a sealed envelope dated 1978 with the message "Do not open until
January 2014"
Alp Toker [Sat, 4 Jan 2014 15:25:02 +0000 (15:25 +0000)]
Move MS predefined type_info out of InitializePredefinedMacros
Instead of keeping it in amongst the macros, build the declaration at Sema init
the same way we do with other predeclared and builtin types.
In practice this means the declaration is marked implicit and therefore won't
show up as an unwanted user-declared type in tooling which has been a
frequently reported issue (though I haven't been able to cook up a test).
Alp Toker [Sat, 4 Jan 2014 13:47:14 +0000 (13:47 +0000)]
Only mark dump() function definitions 'used' in debug builds
This has the dual effect of (1) enabling more dead-stripping in release builds
and (2) ensuring that debug helper functions aren't stripped away in debug
builds, as they're intended to be called from the debugger.
Note that the attribute is applied to definitions rather than declarations in
headers going forward because it's now conditional on NDEBUG:
/// \brief Mark debug helper function definitions like dump() that should not be
/// stripped from debug builds.
Requires corresponding macro added in LLVM r198456.
Ted Kremenek [Sat, 4 Jan 2014 05:52:11 +0000 (05:52 +0000)]
[analyzer] Remove IdempotentOperations checker.
This checker has not been updated to work with interprocedural analysis,
and actually contains both logical correctness issues but also
memory bugs. We can resuscitate it from version control once there
is focused interest in making it a real viable checker again.
Reid Kleckner [Fri, 3 Jan 2014 23:42:00 +0000 (23:42 +0000)]
[ms-cxxabi] Improve vbtable name mangling accuracy
Summary:
This makes us more compatible with MSVC 2012+ and fixes PR17748 where we
would give two tables the same name.
Rather than doing a fresh depth-first traversal of the inheritance graph
for every record's vbtables, now we memoize vbtable paths for each
record. By doing memoization, we end up considering virtual bases of
subobjects that come later in the depth-first traversal. Where
previously we would have ignored a virtual base that we'd already seen,
we now consider it for name mangling purposes without emitting a
duplicate vbtable for it.
Adrian Prantl [Fri, 3 Jan 2014 23:34:30 +0000 (23:34 +0000)]
Debug info: Ensure that the last stop point in a function is still within
the lexical block formed by the compound statement that is the function
body.
Aaron Ballman [Fri, 3 Jan 2014 20:10:54 +0000 (20:10 +0000)]
Refactored Builtin::Context::isPrintfLike and isScanfLike into a helper function. The implementations are identical, except for the format arguments being searched for.
Aaron Ballman [Fri, 3 Jan 2014 18:42:48 +0000 (18:42 +0000)]
Removed one of the string versions of getQualifiedNameAsString, and switched over to using printQualifiedName where possible. No functional changes intended.
[objc] Refactor and improve functionality for the -Wunused-property-ivar warning.
- Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate
all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor
- Don't check immediately after the method body is finished, check when the @implementation is finished.
This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor.
- Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self.
Aaron Ballman [Fri, 3 Jan 2014 16:23:46 +0000 (16:23 +0000)]
Simplifying the mutual exclusion check now that the diagnostics engine knows how to handle Attr objects directly. Updates an associated test case due to the attribute name being properly quoted again.