Commit Graph

25156 Commits

Author SHA1 Message Date
Chad Rosier cb600e2422 Canonicalize loop.
llvm-svn: 156093
2012-05-03 19:50:25 +00:00
Bob Wilson 23cd434202 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!

llvm-svn: 156092
2012-05-03 19:47:19 +00:00
Kaelyn Uhrain 29a8eebc94 Silence unused-variable warning when assertions are disabled.
llvm-svn: 156091
2012-05-03 19:46:38 +00:00
Jordy Rose 1d4660bc51 [analyzer] When promoting constant integers in a comparison, use the larger width of the two to avoid truncation.
llvm-svn: 156089
2012-05-03 19:05:48 +00:00
Richard Smith 84837d5b5a 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.

llvm-svn: 156086
2012-05-03 18:27:39 +00:00
Anna Zaks b3b56bb960 [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.

llvm-svn: 156085
2012-05-03 18:21:28 +00:00
Argyrios Kyrtzidis 9933e3ac88 In StringLiteralParser::init, make sure we emit an error when
failing to lex the string, as suggested by Eli.

Part of rdar://11305263.

llvm-svn: 156081
2012-05-03 17:50:32 +00:00
Chad Rosier f91fb400b3 [driver crash diagnostics] Remove more flags that reference absolute paths that
aren't necessary to reproduce the clang crash.
Part of rdar://11285725

llvm-svn: 156079
2012-05-03 17:07:55 +00:00
Fariborz Jahanian d5f34f9fee objective-c: warn for properties being default synthesized
under -Wobjc-missing-property-synthesis which must be
opted-in. // rdar://11295716

llvm-svn: 156078
2012-05-03 16:43:30 +00:00
David Blaikie c0f5866169 Correctly constify clang::CXXMemberCallExpr::getRecordDecl()
llvm-svn: 156074
2012-05-03 16:25:49 +00:00
Jordy Rose d23232975f [analyzer] Equality ops are like relational ops in that the arguments shouldn't be converted to the result type. Fixes PR12206 and dupe PR12510.
This was probably the original intent of r133041 (also me, a year ago).

llvm-svn: 156062
2012-05-03 07:34:01 +00:00
Bob Wilson f9fbc6a84a Rip out old code for finding libraries in GCC's directories.
llvm-svn: 156058
2012-05-03 05:23:52 +00:00
Argyrios Kyrtzidis 2a5deff59d [PCH] Clear switch case IDs when deserializing a objc method body.
Fixes rdar://11353109 & http://llvm.org/bugs/show_bug.cgi?id=12689

llvm-svn: 156056
2012-05-03 02:26:32 +00:00
Anna Zaks 1655aee1e3 [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.

int *p = malloc(sizeof(int));
ptr = p + (2-x);

llvm-svn: 156052
2012-05-03 02:13:56 +00:00
Anna Zaks f0e9ca8604 [analyzer] Do not assert on constructing SymSymExpr with diff types.
The resulting type info is stored in the SymSymExpr, so no reason not to
support construction of expression with different subexpression types.

llvm-svn: 156051
2012-05-03 02:13:53 +00:00
Anna Zaks 1d3d51a6e6 [analyzer] Add a complexity bound on history tracking.
(Currently, this is only relevant for tainted data.)

llvm-svn: 156050
2012-05-03 02:13:50 +00:00
Anna Zaks 7124b4b124 [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.

llvm-svn: 156049
2012-05-03 02:13:46 +00:00
Richard Trieu 2cdcf82396 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.

llvm-svn: 156045
2012-05-03 01:09:59 +00:00
Argyrios Kyrtzidis 4e5b5c36f4 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.

rdar://11353109

llvm-svn: 156043
2012-05-03 01:01:56 +00:00
Fariborz Jahanian 70ef929561 modern objective-c translator: Fix destructor def.
for __NSContainer_literal.

llvm-svn: 156035
2012-05-02 23:53:46 +00:00
Richard Smith 2331bbfb4e 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.

llvm-svn: 156031
2012-05-02 22:22:32 +00:00
DeLesley Hutchins 90ff4683f7 Thread safety analysis: additional support for smart pointers in lock expressions.
llvm-svn: 156030
2012-05-02 22:18:42 +00:00
Rafael Espindola cd997e02b2 Walk the decls looking for the last one that has an attribute. We do have to walk
them, otherwise we cannot produce an error for both

struct HIDDEN test4; // canonical
struct test4;
struct DEFAULT test4;

and

struct test5; // canonical
struct HIDDEN test5;
struct DEFAULT test5;

llvm-svn: 156016
2012-05-02 20:36:57 +00:00
DeLesley Hutchins d96b46ace2 Thread Safety Analysis: fixed attribute handling for lock_returned attribute.
llvm-svn: 156005
2012-05-02 17:38:37 +00:00
Fariborz Jahanian d7c6777d50 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

llvm-svn: 156004
2012-05-02 17:34:59 +00:00
Douglas Gregor 377f99bc68 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!

llvm-svn: 156003
2012-05-02 17:33:51 +00:00
Douglas Gregor 19fbb8fa81 Introduce the notion of 'ignored' attributes, so that all attributes
we accept are not modeled somehow via Attr.td.

llvm-svn: 155998
2012-05-02 16:18:45 +00:00
Douglas Gregor b2daf8416e Introduce the notion of an attribute that has no direct representation
as an AST node, and fold a number of such attributes into Attr.td.

llvm-svn: 155995
2012-05-02 15:56:52 +00:00
Douglas Gregor 39d59dbd65 Implement the alternate spellings of attributes aligned (as "align")
and const (as "__const") using tblgen, rather than explicitly hacking
them in.

llvm-svn: 155991
2012-05-02 15:16:13 +00:00
Benjamin Kramer c242ef245c 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.

llvm-svn: 155990
2012-05-02 14:55:48 +00:00
Douglas Gregor 0191bf8655 Revert my optimization to AttributeList::getKind() in r155987;
Benjamin has suggested a better approach.

llvm-svn: 155989
2012-05-02 14:50:50 +00:00
Douglas Gregor 25c1609648 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>.

llvm-svn: 155988
2012-05-02 14:34:16 +00:00
Douglas Gregor adfe5afe38 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>.

llvm-svn: 155987
2012-05-02 14:24:30 +00:00
James Molloy cebf75e8ca 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"

llvm-svn: 155981
2012-05-02 07:56:14 +00:00
Andrew Trick d4cfa2fe4c Fix cmake. Remaining two ClangCC1Options deps.
llvm-svn: 155977
2012-05-02 05:31:31 +00:00
Richard Smith 38f7c7bca5 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.

llvm-svn: 155975
2012-05-02 01:29:43 +00:00
Andrew Trick 4d77ceaa22 Speculatively fix windows cmake builders.
Really just a wild stab in the dark.

llvm-svn: 155974
2012-05-02 01:23:51 +00:00
Ted Kremenek 170641b0e0 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.

Fixes <rdar://problem/11327497>

llvm-svn: 155971
2012-05-02 00:31:29 +00:00
Anna Zaks 70de772d45 [analyzer] RetainRelease: Self assignment should not suppress a leak
warning.

llvm-svn: 155966
2012-05-02 00:15:40 +00:00
Kaelyn Uhrain 7179205f49 Try harder to recognize hidden tag type names in potential declarations instead
of giving unhelpful errors about undeclared identifers and missing semicolons.

llvm-svn: 155965
2012-05-02 00:11:40 +00:00
Anna Zaks 06be9117bf [analyzer] Fix an assertion failure triggered by the analyzer buildbot.
llvm-svn: 155964
2012-05-02 00:05:23 +00:00
Anna Zaks 263b7e016e [analyzer] Fix the 'ptr = ptr' false negative in the Malloc checker.
llvm-svn: 155963
2012-05-02 00:05:20 +00:00
Douglas Gregor 0e6fc1ab6d 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>.

llvm-svn: 155961
2012-05-01 23:37:00 +00:00
Douglas Gregor f73e2604b1 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.

llvm-svn: 155958
2012-05-01 23:07:34 +00:00
Eli Friedman 169ec35bb3 Add a missing RequireCompleteType call when synthesizing properties. <rdar://problem/11333367>.
While I'm here, fix source locations for other diagnostics related to property synthesis.

llvm-svn: 155953
2012-05-01 22:26:06 +00:00
Argyrios Kyrtzidis 5f20a7e02e Utilize getLocStart()/getLocEnd() on my recent change.
llvm-svn: 155952
2012-05-01 22:19:11 +00:00
Ted Kremenek f56d4f2991 Teach SValBuilder to handle casts of symbolic pointer values to an integer twice. Fixes <rdar://problem/11212866>.
llvm-svn: 155950
2012-05-01 21:58:29 +00:00
Patrick Beard 2565c59631 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).

llvm-svn: 155949
2012-05-01 21:47:19 +00:00
Anna Zaks b35437a85e [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.

llvm-svn: 155944
2012-05-01 21:10:26 +00:00
Rafael Espindola a01ff786ed Extend the error about incompatible visibility attributes in different
decls to work on function templates specializations.

llvm-svn: 155943
2012-05-01 20:58:29 +00:00