Sean Callanan [Fri, 4 May 2012 18:22:53 +0000 (18:22 +0000)]
IsTailPaddedMemberArray uses a FieldDecl's
getTypeSourceInfo() without checking for NULL.
FieldDecls may have NULL TypeSourceInfo, and in
fact some FieldDecls generated by Clang -- and
all FieldDecls generated by LLDB -- have no
TypeSourceInfo.
This patch makes IsTailPaddedMemberArray check
for NULL.
Douglas Gregor [Fri, 4 May 2012 16:32:21 +0000 (16:32 +0000)]
Move Sema::RequireCompleteType() and Sema::RequireCompleteExprType()
off PartialDiagnostic. PartialDiagnostic is rather heavyweight for
something that is in the critical path and is rarely used. So, switch
over to an abstract-class-based callback mechanism that delays most of
the work until a diagnostic is actually produced. Good for ~11k code
size reduction in the compiler and 1% speedup in -fsyntax-only on the
code in <rdar://problem/11004361>.
James Molloy [Fri, 4 May 2012 10:55:22 +0000 (10:55 +0000)]
Fix handling of wint_t - we can't assume wint_t is purely an integer promotion of wchar_t - they may differ in signedness.
Teach ASTContext about WIntType, and have it taken from TargetInfo like WCharType. Should fix test/Sema/format-strings.c for ARM, with the exception of one subtest which will fail if wint_t and wchar_t are the same size and wint_t is signed, wchar_t is unsigned.
There'll be a followup commit to fix that.
Reviewed by Chandler and Hans at http://llvm.org/reviews/r/8
Alexey Samsonov [Fri, 4 May 2012 07:39:27 +0000 (07:39 +0000)]
This patch adds a new Clang compiler flag "-gline-tables-only".
It reduces the amount of emitted debug information:
1) DIEs in .debug_info have types DW_TAG_compile_unit, DW_TAG_subprogram,
DW_TAG_inlined_subroutine (for opt builds) and DW_TAG_lexical_block only.
2) .debug_str contains only function names.
3) No debug data for types/namespaces/variables is emitted.
4) The data in .debug_line is enough to produce valid stack traces with
function names and line numbers.
[libclang] Bring back BodyIndexer::TraverseCXXOperatorCallExpr which
was removed in r155969 to address a deficiency of RecursiveASTVisitor
prior to recent changes on it.
Make RecursiveASTVisitor fully data recursive on Stmts, with
minimal disruption on its clients.
Unlike the previous data-recursive scheme, Traverse*Stmt methods are
always getting called. The base methods of RecursiveASTVisitor will enqueue
the sub-statements instead of calling TraverseStmt on them.
Clients that override a Traverse*Stmt method and call TraverseStmt will
still function as function-recursive traversal; if a client wants to
enqueue a sub-statement in its override method it can do it like this:
[inside the override method]
StmtQueueAction StmtQueue(*this);
StmtQueue.queue(Stmt->getSubStmt());
Fix non-deterministic iteration order when walking the specializations
of templates by using the newly introduce FoldingSetVector. This
preserves insertion order for all iteration of specializations.
I've also included a somewhat terrifying testcase that rapidly builds up
a large number of functions. This is enough that any system with ASLR
will have non-deterministic debug information generated for the test
case without the fix here as the debug information is generated in part
by walking these specializations.
Douglas Gregor [Thu, 3 May 2012 23:18:44 +0000 (23:18 +0000)]
Split DeclarationName::getFETokenInfoAsVoid() into hot/cold paths and
(trivially) make DeclContext::lookup()'s const version inlinable. Good
for 0.3% on <rdar://problem/11004361>.
Chad Rosier [Thu, 3 May 2012 22:38:00 +0000 (22:38 +0000)]
[driver - crash diagnostics] Convert the flags back to an array of strings and use
array_lengthof. Also, append the new filename with correct preprocessed suffix.
Last part of rdar://11285725
Richard Smith [Thu, 3 May 2012 22:18:20 +0000 (22:18 +0000)]
Use the standard values for the __cplusplus macro, even when in GNU mode. GCC
dropped its prior behavior of always defining __cplusplus to 1 in GNU mode in
version 4.7.
Douglas Gregor [Thu, 3 May 2012 21:25:24 +0000 (21:25 +0000)]
Do not keep track of the set of visited Objective-C containers when
performing the search for overridden methods. We very rarely see the
same container twice, and in those rare cases we still have the
fallback of the second SmallPtrSet to eliminate duplicates. Good for
~1.5% -fsyntax-only speedup on the code in <rdar://problem/11004361>.
Bob Wilson [Thu, 3 May 2012 19:47:19 +0000 (19:47 +0000)]
Disable -Wformat-extra-args for arguments defined in system headers.
Some of the NSAssert macros in OS X 10.7 are implemented in a way that
adds extra arguments that trigger the -Wformat-extra-args warning.
Earlier versions of clang failed to detect those -Wformat issues, but now
that clang is reporting those problems, we need to quiet them since there's
nothing to be done to fix them. <rdar://problem/11317765>
I don't know how to write a testcase for this. Suggestions welcome.
Patch by Ted Kremenek!
Richard Smith [Thu, 3 May 2012 18:27:39 +0000 (18:27 +0000)]
Add -Wimplicit-fallthrough warning flag, which warns on fallthrough between
cases in switch statements. Also add a [[clang::fallthrough]] attribute, which
can be used to suppress the warning in the case of intentional fallthrough.
Patch by Alexander Kornienko!
The handling of C++11 attribute namespaces in this patch is temporary, and will
be replaced with a cleaner mechanism in a subsequent patch.
Anna Zaks [Thu, 3 May 2012 18:21:28 +0000 (18:21 +0000)]
[analyzer] CString Checker: Do not split the path unless the user
specifically checks for equality to null.
Enforcing this general practice, which keeps the analyzer less
noisy, in the CString Checker. This change suppresses "Assigned value is
garbage or undefined" warning in the added test case.
Richard Smith [Thu, 3 May 2012 17:56:49 +0000 (17:56 +0000)]
Fix a couple of cases of (innocuous) unmarked fallthrough. At least one of these
was unintentional. Found by -Wimplicit-fallthrough, patch by Alexander Kornienko!
Anna Zaks [Thu, 3 May 2012 02:13:56 +0000 (02:13 +0000)]
[analyzer] Conjure a symbol to ensure we can identify pointer arithmetic
We need to identify the value of ptr as
ElementRegion (result of pointer arithmetic) in the following code.
However, before this commit '(2-x)' evaluated to Unknown value, and as
the result, 'p + (2-x)' evaluated to Unknown value as well.
Anna Zaks [Thu, 3 May 2012 02:13:46 +0000 (02:13 +0000)]
[analyzer] Revert the functional part of r155944.
The change resulted in multiple issues on the buildbot, so it's not
ready for prime time. Only enable history tracking for tainted
data(which is experimental) for now.
John McCall [Thu, 3 May 2012 01:34:46 +0000 (01:34 +0000)]
Merge x86-64-abi-sret-vs-2word-struct-param.cpp into the generic
x86_64-arguments.cpp test file and be sure to test the coerced
case as well. Thanks to Wei-Ren Chen for bringing this test
to my attention.
Richard Trieu [Thu, 3 May 2012 01:09:59 +0000 (01:09 +0000)]
Fix a note without a SourceLocation.
#define TEST int y; int x = y;
void foo() {
TEST
}
-Wuninitialized gives this warning:
invalid-loc.cc:4:3: warning: variable 'y' is uninitialized when used here
[-Wuninitialized]
TEST
^~~~
invalid-loc.cc:2:29: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
^
note: initialize the variable 'y' to silence this warning
1 warning generated.
The second note lacks filename, line number, and code snippet. This change
will remove the fixit and only point to variable declaration.
invalid-loc.cc:4:3: warning: variable 'y' is uninitialized when used here
[-Wuninitialized]
TEST
^~~~
invalid-loc.cc:2:29: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
^
invalid-loc.cc:4:3: note: variable 'y' is declared here
TEST
^
invalid-loc.cc:2:14: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
^
1 warning generated.
In StringLiteralParser::init(), fail gracefully if the string is
not as we expect; it may be due to racing issue of a file coming from PCH
changing after the PCH is loaded.
Richard Smith [Wed, 2 May 2012 22:22:32 +0000 (22:22 +0000)]
Revert most of r154844, which was disabled in r155975. Keep around the
refactorings in that revision, and some of the subsequent bugfixes, which
seem to be relevant even without delayed exception specification parsing.
Modern objective-c translation: Fixing couple of bugs
related to laying out ivar structs and accessing non-fragile-ivar
in more compilated cases. // rdar://11323187
Douglas Gregor [Wed, 2 May 2012 17:33:51 +0000 (17:33 +0000)]
Replace the StringSwitch in AttributeList::getKind() with a
TableGen-generated StringMatcher, for a 1.2% speedup in -fparse-only
time in <rdar://problem/11004361>. Thanks to Benjamin for pointing me
at StringMatcher!
David Blaikie [Wed, 2 May 2012 15:24:47 +0000 (15:24 +0000)]
Fix same line doxycomments so they comment the adjacent field.
Without the '<' prefix in the doxycomment these comments were incorrectly
attached to the proceeding comment on the next line, rather than the
preceeding one.
Benjamin Kramer [Wed, 2 May 2012 14:55:48 +0000 (14:55 +0000)]
Driver: Turn the default value for -fmath-errno into a proper target hook and disable it by default on more platforms.
For now -fno-math-errno is the default on BSD-derived platforms (Darwin,
DragonFlyBSD, FreeBSD, NetBSD, OpenBSD). If the default is not right for
your platform, please yell. I only verified the result with the default
compilers on Darwin and FreeBSD.
Douglas Gregor [Wed, 2 May 2012 14:34:16 +0000 (14:34 +0000)]
Replace a ConsumeAnyToken() call with ConsumeToken() when we know
we're looking at a normal token. Tiny positive impact -fsyntax-only
time for <rdar://problem/11004361>.
Douglas Gregor [Wed, 2 May 2012 14:24:30 +0000 (14:24 +0000)]
Replace the StringSwitch in AttributeList::getKind(const
IdentifierInfo *) with a static StringMap, improving -fsyntax-only
performance by 1% for the example in <rdar://problem/11004361>.
James Molloy [Wed, 2 May 2012 07:56:14 +0000 (07:56 +0000)]
Fix forwarding of -fpack-struct from driver to CC1, and add a test.
-fpack-struct's handling has changed in CC1 (one of only two flags that needed changing) because the driver treats "-fpack-struct" as a boolean flag, and CC1 (did) treat it as an option with a separated value.
This change causes -fpack-struct=X to be forwarded correctly to -fpack-struct=X instead of erroneously to "-fpack-struct X"
Richard Smith [Wed, 2 May 2012 01:29:43 +0000 (01:29 +0000)]
Disable our non-standard delayed parsing of exception specifications. Delaying
the parsing of such things appears to be a conforming extension, but it breaks
libstdc++4.7's std::pair.
Ted Kremenek [Wed, 2 May 2012 00:31:29 +0000 (00:31 +0000)]
Refine analyzer diagnostics by adding an expression "cone-of-influence" to reverse track interesting
values through interesting expressions. This allows us to map from interesting values in a caller
to interesting values in a caller, thus recovering some precision in diagnostics lost from IPA.
Richard Smith [Wed, 2 May 2012 00:30:48 +0000 (00:30 +0000)]
Unrevert r155951, reverted in r155962, with two changes:
* Work around build failures due to gcc 4.2 bugs.
* Remove BodyIndexer::TraverseCXXOperatorCallExpr, which was not being called
prior to this change, and whose presence disables a RecursiveASTVisitor
stack space optimization after this change.
Kaelyn Uhrain [Wed, 2 May 2012 00:11:40 +0000 (00:11 +0000)]
Try harder to recognize hidden tag type names in potential declarations instead
of giving unhelpful errors about undeclared identifers and missing semicolons.
Douglas Gregor [Tue, 1 May 2012 23:37:00 +0000 (23:37 +0000)]
Eliminate Sema::CompareMethodParamsInBaseAndSuper() entirely, by
folding its one check into the normal path for checking overridden
Objective-C methods. Good for another 3.6% speedup on the test case in
<rdar://problem/11004361>.
Douglas Gregor [Tue, 1 May 2012 23:07:34 +0000 (23:07 +0000)]
The semantic checking that verifies whether an Objective-C method
declared in a subclass has consistent parameter types with a method
having the same selector in a superclass performs a significant number
of lookups into the class hierarchy. In the example in
<rdar://problem/11004361>, we spend 4.7% of -fsyntax-only time in
these lookups.
Optimize away most of the calls to this routine
(Sema::CompareMethodParamsInBaseAndSuper) by first checking whether we
have ever seen *any* method with that selector (using the global
selector table). Since most selectors are unique, we can avoid the
cost of this name lookup in many cases, for a 3.3% speedup.