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.
Richard Smith [Tue, 1 May 2012 21:58:31 +0000 (21:58 +0000)]
Fix RecursiveASTVisitor's data recursion to call the Traverse* functions if they
have been overridden in the derived class. Also, remove a non-functional
implementation of an incorrect optimization for ParenExprs.
Patrick Beard [Tue, 1 May 2012 21:47:19 +0000 (21:47 +0000)]
Clean up changes suggested by Douglas Gregor:
BuildObjCNumericLiteral() and BuildObjCBoxedExpr() now both using
PerformCopyInitialization() rather than PerformImplicitConversion(),
which suppresses errors.
In BuildObjCBoxedExpr(): no longer calling .getCanonicalType(),
ValueType->getAs() will remove the minimal amount of sugar.
Using ValueType->isBuiltinType() instead of isa<BuiltinType>(ValueType).
Anna Zaks [Tue, 1 May 2012 21:10:26 +0000 (21:10 +0000)]
[analyzer] Construct a SymExpr even when the constraint solver cannot
reason about the expression.
This essentially keeps more history about how symbolic values were
constructed. As an optimization, previous to this commit, we only kept
the history if one of the symbols was tainted, but it's valuable keep
the history around for other purposes as well: it allows us to avoid
constructing conjured symbols.
Specifically, 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.
int *p = malloc(sizeof(int));
ptr = p + (2-x);
This change brings 2% slowdown on sqlite. Fixes radar://11329382.
John McCall [Tue, 1 May 2012 20:28:00 +0000 (20:28 +0000)]
During block layout, after padding up to the max field alignment,
the alignment might actually exceed the max field alignment; don't
assert in this case.
Douglas Gregor [Tue, 1 May 2012 20:23:02 +0000 (20:23 +0000)]
In C++11 mode, implement the C++11 semantics for
[basic.lookup.classref]p1 and p4, which concerns name lookup for
nested-name-specifiers and template names, respectively, in a member
access expression. C++98/03 forces us to look both in the scope of the
object and in the current scope, then compare the results. C++11 just
takes the result from the scope of the object, if something is
found. Fixes <rdar://problem/11328502>.
Chad Rosier [Tue, 1 May 2012 18:11:51 +0000 (18:11 +0000)]
Get rid of storelv4si builtin as it can be expressed directly. This is general
goodness because it provides opportunites to cleanup things. For example,
John McCall [Tue, 1 May 2012 17:32:20 +0000 (17:32 +0000)]
Restructure some of the member-pointer tests, implicitly
removing some that were added without a triple (and moving
their tests into files that appropriately test multiple
architectures).
John McCall [Tue, 1 May 2012 06:13:13 +0000 (06:13 +0000)]
Abstract the emission of global destructors into ABI-specific code
and only consider using __cxa_atexit in the Itanium logic. The
default logic is to use atexit().
Emit "guarded" initializers in Microsoft mode unconditionally.
This is definitely not correct, but it's closer to correct than
just not emitting the initializer.
David Blaikie [Tue, 1 May 2012 06:05:57 +0000 (06:05 +0000)]
PR12710 - broken default argument handling for templates.
I broke this in r155838 by not actually instantiating non-dependent default arg
expressions. The motivation for that change was to avoid producing duplicate
conversion warnings for such default args (we produce them once when we parse
the template - there's no need to produce them at each instantiation) but
without actually instantiating the default arg, things break in weird ways.
Technically, I think we could still get the right diagnostic experience without
the bugs if we instantiated the non-dependent args (for non-dependent params
only) immediately, rather than lazily. But I'm not sure if such a refactoring/
change would be desirable so here's the conservative fix for now.
Ted Kremenek [Tue, 1 May 2012 05:28:27 +0000 (05:28 +0000)]
Teach RetainCountchecker about IORegistryEntrySearchCFProperty returning retained objects. I know there is an SDK enhancement request for this to have the cf_returns_retained annotation, so this is just a stop gap.
John McCall [Tue, 1 May 2012 05:23:51 +0000 (05:23 +0000)]
Refactor the C++ ABI code a little bit to take advantage of
what I'm going to treat as basically universal properties of
array-cookie code. Implement MS array cookies on top of that.
Based on a patch by Timur Iskhodzhanov!
John McCall [Tue, 1 May 2012 02:33:44 +0000 (02:33 +0000)]
When mangling a synthetic function declaration, we might not have
type-source information for its parameters. Don't crash when
mangling them in the MS C++ ABI. Patch by Timur Iskhodzhanov!