Commit Graph

12108 Commits

Author SHA1 Message Date
Richard Smith bfdb108fc5 Fix parsing of trailing-return-type. Types are syntactically prohibited from
being defined here: [] () -> struct S {} does not define struct S.

In passing, implement DR1318 (syntactic disambiguation of 'final').

llvm-svn: 152551
2012-03-12 08:56:40 +00:00
Richard Smith c5b0552055 Fix parsing of type-specifier-seq's. Types are syntactically allowed to be
defined here, but not semantically, so

  new struct S {};

is always ill-formed, even if there is a struct S in scope.

We also had a couple of bugs in ParseOptionalTypeSpecifier caused by it being
under-loved (due to it only being used in a few places) so merge it into
ParseDeclarationSpecifiers with a new DeclSpecContext. To avoid regressing, this
required improving ParseDeclarationSpecifiers' diagnostics in some cases. This
also required teaching ParseSpecifierQualifierList about constexpr... which
incidentally fixes an issue where we'd allow the constexpr specifier in other
bad places.

llvm-svn: 152549
2012-03-12 07:56:15 +00:00
Nick Lewycky 74655a5d67 Fix typo in comment, 'langauge' -> 'language'.
llvm-svn: 152547
2012-03-11 23:14:21 +00:00
David Blaikie bbafb8a745 Unify naming of LangOptions variable/get function across the Clang stack (Lex to AST).
The member variable is always "LangOpts" and the member function is always "getLangOpts".

Reviewed by Chris Lattner

llvm-svn: 152536
2012-03-11 07:00:24 +00:00
Douglas Gregor 50a3cdddda When determining whether an identifier followed by a '<' in a member
access expression is the start of a template-id, ignore function
templates found in the context of the entire postfix-expression. Fixes
PR11856.

llvm-svn: 152520
2012-03-10 23:52:41 +00:00
John McCall 113bee0536 Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr to
track whether the referenced declaration comes from an enclosing
local context.  I'm amenable to suggestions about the exact meaning
of this bit.

llvm-svn: 152491
2012-03-10 09:33:50 +00:00
Argyrios Kyrtzidis 224ec821da [Sema] A tag decl that is marked as invalid and is used in a decl-spec,
should not impede creating a proper TypeLoc info for the decl-spec.

This improves our semantic error recovery.

llvm-svn: 152481
2012-03-10 03:20:58 +00:00
Ted Kremenek 8fdb59f979 [analyzer] fix regression in analyzer of NOT actually aborting on Stmts it doesn't understand. We registered
as aborted, but didn't treat such cases as sinks in the ExplodedGraph.

Along the way, add basic support for CXXCatchStmt, expanding the set of code we actually analyze (hopefully correctly).

Fixes: <rdar://problem/10892489>
llvm-svn: 152468
2012-03-10 01:34:17 +00:00
Richard Smith 4e9e523fcf Assign APValues by swapping from a temporary. Removes a bunch of unnecessary
copy-construction, which Daniel Dunbar reports as giving a 0.75% speedup on
403.gcc/combine.c. The performance differences on my constexpr torture tests
are below the noise floor.

llvm-svn: 152455
2012-03-10 00:28:11 +00:00
Richard Smith 2a70e65436 Improve diagnostics for UCNs referring to control characters and members of the
basic source character set in C++98. Add -Wc++98-compat diagnostics for same in
literals in C++11. Extend such support to cover string literals as well as
character literals, and mark N2170 as done.

This seems too minor to warrant a release note to me. Let me know if you disagree.

llvm-svn: 152444
2012-03-09 22:27:51 +00:00
Anna Zaks 394d07ea88 [analyzer] Add support for NoRedundancy inlining mode.
We do not reanalyze a function, which has already been analyzed as an
inlined callee. As per PRELIMINARY testing, this gives over
50% run time reduction on some benchmarks without decreasing of the
number of bugs found.

Turning the mode on by default.

llvm-svn: 152440
2012-03-09 21:14:01 +00:00
Anna Zaks c255577062 CallGraph: Add getNode() method, constify.
llvm-svn: 152439
2012-03-09 21:13:53 +00:00
Daniel Dunbar 4fccc877c9 Revert r152430 "[AST] Mark ASTContext::getTypeInfo and some friends as
LLVM_READONLY.", getTypeInfo() is totally not READONLY, which I should have
probably noticed given that I made it so mere hours ago. Oops.

llvm-svn: 152434
2012-03-09 20:41:19 +00:00
Matt Beaumont-Gay 639ac334c7 Add a helper to get a CXXConstructExpr from a CXXNewExpr.
llvm-svn: 152433
2012-03-09 20:36:34 +00:00
Daniel Dunbar d5744b9910 [AST] Mark Expr::Ignore*() functions as LLVM_READONLY.
llvm-svn: 152431
2012-03-09 20:02:56 +00:00
Daniel Dunbar b150e1b1af [AST] Mark ASTContext::getTypeInfo and some friends as LLVM_READONLY.
llvm-svn: 152430
2012-03-09 20:02:54 +00:00
Daniel Dunbar 0fbc2bd499 [AST] Mark Expr::getExprLoc() as LLVM_READONLY.
llvm-svn: 152429
2012-03-09 20:02:51 +00:00
Daniel Dunbar e4775e1659 [AST/etc] Mark {getSourceRange(),getStartLoc(),getEndLoc()} as LLVM_READONLY.
- The theory here is that we have these functions sprinkled in all over the
   place. This should allow the optimizer to at least realize it can still do
   load CSE across these calls.
 - I blindly marked all instances as such, even though the optimizer can infer
   this attribute in some instances (some of the inline ones) as that was easier
   and also, when given the choice between thinking and not thinking, I prefer
   the latter.

You might think this is mere frivolity, but actually this is good for a .7 -
1.1% speedup on 403.gcc/combine.c, JSC/Interpreter.cpp,
OGF/NSBezierPath-OAExtensions.m.

llvm-svn: 152426
2012-03-09 19:35:29 +00:00
Daniel Dunbar ddb83c7194 [AST/Sema] Add {CXXBaseSpecifier,Declarator,DeclSpec,TypeLoc,UnqualifiedId}::getLoc{Start,End}.
llvm-svn: 152418
2012-03-09 18:34:54 +00:00
Daniel Dunbar cdf295c532 [AST] Define a few more key getLocStart() implementations.
- This cuts the # of getSourceRange calls by 60% on
   OGF/NSBezierPath-OAExtensions.m.

llvm-svn: 152412
2012-03-09 15:39:24 +00:00
Daniel Dunbar b0ab5e9f5c [AST] Reimplement Stmt::getLoc{Start,End} to dispatch to subclass overloads.
- getSourceRange() can be very expensive, we should try to avoid it if at all possible.

In conjunction with the previous commit I measured a ~2% speedup on 403.gcc/combine.c and a 3% speedup on OmniGroupFrameworks/NSBezierPath-OAExtensions.m.

llvm-svn: 152411
2012-03-09 15:39:19 +00:00
Daniel Dunbar b507f27185 [AST] Add {DeclRefExpr,MemberExpr,ImplicitCastExpr}::{getLocStart,getLocEnd} methods.
- There are probably a lot more of these worth adding, but these are a start at hitting some of the exprs for which getSourceRange().getBegin() is a poor substitute for getLocStart().

llvm-svn: 152410
2012-03-09 15:39:15 +00:00
Daniel Dunbar d863d31f4b [AST] Add DeclaratioName::getLoc{Start,End} for consistency.
llvm-svn: 152409
2012-03-09 15:39:11 +00:00
Daniel Dunbar 7b93f636e0 [Basic] Rename LangOptions::NoInline to NoInlineDefine, to make things a bit
more obvious.

llvm-svn: 152408
2012-03-09 15:39:08 +00:00
Hans Wennborg aa8c61cf94 -Wformat-non-iso: warn about positional arguments (pr12017)
This renames the -Wformat-non-standard flag to -Wformat-non-iso,
rewords the current warnings a bit (pointing out that a format string
is not supported by ISO C rather than being "non standard"),
and adds a warning about positional arguments.

llvm-svn: 152403
2012-03-09 10:10:54 +00:00
Richard Smith 768ceccc75 Literal operators can't have default arguments.
llvm-svn: 152394
2012-03-09 08:16:22 +00:00
Richard Smith bcc22fc4e1 Support for raw and template forms of numeric user-defined literals,
and lots of tidying up.

llvm-svn: 152392
2012-03-09 08:00:36 +00:00
Daniel Dunbar c647587aa3 [AST] Memoize ASTContext::getTypeInfo().
- On -emit-llvm-only of 403.gcc/combine.c, for example, we make 160k calls to
   getTypeInfo but only ever deal with 680 some distinct types.

I saw these speedups (user time):
  403.gcc/combine.c -- 3.1%
  OmniGroupFrameworks/NSBezierPath-OAExtensions.m -- 3.6%
  JavaScriptCore/Interpreter.cpp -- 1.4%
which seems pretty sweet.

I ran some histograms on those compiles and we end up doing a ton of
getTypeInfo() on 'char' and 'int'. I tried splitting out a fast path for builtin
types, but this wasn't a win. Still kinda seems like we could be doing better
here.

llvm-svn: 152377
2012-03-09 04:12:54 +00:00
Daniel Dunbar 3c38d435c6 [AST] NestedNameSpecifier's ctor/dtor are trivial and should be inlined.
llvm-svn: 152365
2012-03-09 01:51:59 +00:00
Daniel Dunbar 198e16fd3a [AST] Type::isVoidType() is trivial and should be inlined.
llvm-svn: 152364
2012-03-09 01:51:56 +00:00
Daniel Dunbar 9d35581907 [AST] Reduce Decl::getASTContext() calls.
- This function is not at all free; pass it around along some hot paths instead
   of recomputing it deep inside various VarDecl methods.

llvm-svn: 152363
2012-03-09 01:51:51 +00:00
Ted Kremenek 1e809b4c4c [analyzer] Implement basic path diagnostic pruning based on "interesting" symbols and regions.
Essentially, a bug centers around a story for various symbols and regions.  We should only include
the path diagnostic events that relate to those symbols and regions.

The pruning is done by associating a set of interesting symbols and regions with a BugReporter, which
can be modified at BugReport creation or by BugReporterVisitors.

This patch reduces the diagnostics emitted in several of our test cases.  I've vetted these as
having desired behavior.  The only regression is a missing null check diagnostic for the return
value of realloc() in test/Analysis/malloc-plist.c.  This will require some investigation to fix,
and I have added a FIXME to the test case.

llvm-svn: 152361
2012-03-09 01:13:14 +00:00
Anna Zaks 0af3e06ff6 [analyzer] Rework inlining related command line options.
- Remove -analyzer-inline-call.
 - Add -analyzer-ipa=[none|inlining]
 - Add -analyzer-inlining-mode to allow experimentation for
different performance tuning methods.

llvm-svn: 152351
2012-03-08 23:16:35 +00:00
Richard Smith 7d182a7909 Fix a couple of issues with literal-operator-id parsing, and provide recovery
for a few kinds of error. Specifically:

Since we're after translation phase 6, the "" token might be formed by multiple
source-level string literals. Checking the token width is not a correct way of
detecting empty string literals, due to escaped newlines. Diagnose and recover
from a missing space between "" and suffix, and from string literals other than
"", which are followed by a suffix.

llvm-svn: 152348
2012-03-08 23:06:02 +00:00
Richard Smith 812924502b When checking the encoding of an 8-bit string literal, don't just check the
first codepoint! Also, don't reject empty raw string literals for spurious
"encoding" issues. Also, don't rely on undefined behavior in ConvertUTF.c.

llvm-svn: 152344
2012-03-08 21:59:28 +00:00
Daniel Dunbar 47c32287d9 [AST] Clean up NamedDecl::getUnderlyingDecl() change a bit.
llvm-svn: 152332
2012-03-08 20:29:02 +00:00
Daniel Dunbar b743157df3 [AST] APValue: Split the fast path of MakeUninit to be inline.
- This change seems to be a tiny loss on 403.gcc/combine.c (.2%), but I think
   it is the right thing to do.

llvm-svn: 152330
2012-03-08 20:28:55 +00:00
Daniel Dunbar b29f685d3c [Basic] PartialDiagnostic: Manual split out the cold part of freeStorage(), the
hot path will typically profitably get inlined (based on what I see from the
users of PartialDiagnostic).

llvm-svn: 152322
2012-03-08 18:43:59 +00:00
Daniel Dunbar 166ea9ad8b [AST] Change NamedDecl::getUnderlyingDecl() to inline the fast (and incredibly common) path.
llvm-svn: 152321
2012-03-08 18:20:41 +00:00
Rafael Espindola df88f6fe98 Replace MarkVarRequired with a more generic
HandleCXXStaticMemberVarInstantiation. Suggested by Argyrios.

llvm-svn: 152320
2012-03-08 15:51:03 +00:00
Richard Smith 39570d0020 Add support for cooked forms of user-defined-integer-literal and
user-defined-floating-literal. Support for raw forms of these literals
to follow.

llvm-svn: 152302
2012-03-08 08:45:32 +00:00
Daniel Dunbar d043733ad9 [AST] Change Type::isIntegerType to be inlined(). It is very popular.
llvm-svn: 152289
2012-03-08 02:52:18 +00:00
Richard Smith 0df56f4a90 Implement C++11 [lex.ext]p10 for string and character literals: a ud-suffix not
starting with an underscore is ill-formed.

Since this rule rejects programs that were using <inttypes.h>'s macros, recover
from this error by treating the ud-suffix as a separate preprocessing-token,
with a DefaultError ExtWarn. The approach of treating such cases as two tokens
is under discussion for standardization, but is in any case a conforming
extension and allows existing codebases to keep building while the committee
makes up its mind.

Reword the warning on the definition of literal operators not starting with
underscores (which are, strangely, legal) to more explicitly state that such
operators can't be called by literals. Remove the special-case diagnostic for
hexfloats, since it was both triggering in the wrong cases and incorrect.

llvm-svn: 152287
2012-03-08 02:39:21 +00:00
Douglas Gregor 3f28ec28d5 Loosen the precondition of isCXXInstanceMember() to simply return
"false" for declarations that aren't members of classes. Fixes PR12106.

llvm-svn: 152284
2012-03-08 02:08:05 +00:00
Daniel Dunbar 9e19f13416 Sema: Don't emit a gajillion calls to sanity() -- an empty function -- in NDEBUG
builds. Sheesh.

llvm-svn: 152279
2012-03-08 01:43:06 +00:00
Richard Smith 75b67d6dc5 User-defined literal support for character literals.
llvm-svn: 152277
2012-03-08 01:34:56 +00:00
Douglas Gregor 0cf55e99c6 Streamline BalancedDelimiterTracker, by eliminating the duplicate
paren/brace/bracket tracking (the Consume* functions already did it),
removing the use of ConsumeAnyToken(), and moving the hot paths inline
with the error paths out-of-line.

llvm-svn: 152274
2012-03-08 01:00:17 +00:00
Fariborz Jahanian 80f8b4e7cb improve on diagnostic when block captures uninitialized
block variable. // rdar://10817031

llvm-svn: 152273
2012-03-08 00:52:24 +00:00
Anna Zaks c000e7ed3d Add a basic CallGraph to Analysis.
The final graph contains a single root node, which is a parent of all externally available functions(and 'main'). As well as a list of Parentless/Unreachable functions, which are either truly unreachable or are unreachable due to our analyses imprecision.

The analyzer checkers debug.DumpCallGraph or debug.ViewGraph can be used to look at the produced graph.

Currently, the graph is not very precise, for example, it entirely skips edges resulted from ObjC method calls.

llvm-svn: 152272
2012-03-08 00:42:23 +00:00
Fariborz Jahanian 429fadb8e2 improve on diagnostic and provide a fixit hint when
an uninitialized block variable is being called inside the
block literal. // rdar://10817031

llvm-svn: 152271
2012-03-08 00:22:50 +00:00