Richard Smith [Sat, 29 Oct 2011 20:57:55 +0000 (20:57 +0000)]
constexpr function substitution:
Track the function invocation where an lvalue referring to a constexpr function
parameter originated from, and use it to substitute the correct argument and to
determine whether such an argument's lifetime has ended.
Richard Smith [Sat, 29 Oct 2011 00:50:52 +0000 (00:50 +0000)]
Rename Expr::Evaluate to Expr::EvaluateAsRValue to make it clear that it will
implicitly perform an lvalue-to-rvalue conversion if used on an lvalue
expression. Also improve the documentation of Expr::Evaluate* to indicate which
of them will accept expressions with side-effects.
Ted Kremenek [Sat, 29 Oct 2011 00:12:39 +0000 (00:12 +0000)]
Start work on SerializedDiagnosticPrinter, a new DiagnosticConsumer that serializes out the diagnostics for a given translation unit to a bit code file. This is a WIP.
The motivation for this new DiagnosticConsumer is to provide a way for tools invoking the compiler
to get its diagnostics via a libclang interface, rather than textually parsing the compiler output.
This gives us flexibility to change the compiler's textual output, but have a structured data format
for clients to use to get the diagnostics via a stable API.
I have no tests for this, but llvm-bcanalyzer so far shows that the emitted file is well-formed.
Douglas Gregor [Fri, 28 Oct 2011 23:02:54 +0000 (23:02 +0000)]
Give __STDC_VERSION__ the value 201001L when we're in C1x mode. The
committee hasn't set a value for __STDC_VERSION__ yet, so this is a
placeholder. But at least it's > 199901L.
[libclang] Introduce use of CINDEXTEST_FAILONERROR environment variable which, if set,
will cause c-index-test to return as failed if a compiler error occurred.
[ARC] Do not transfer ARC ownership if the cast is going to result in r-value,
in which case the ownership is redundant. Thanks to John for the suggestion.
[PCH] Keep track of file-level declarations that are contained by files.
Introduce a FILE_SORTED_DECLS [de]serialization record that contains
a file sorted array of file-level DeclIDs in a PCH/Module.
The rationale is to allow "targeted" deserialization of decls inside
a range of a source file.
Cocoa PCH increased by 0.8%
Difference of creation time for Cocoa PCH is below the noise level.
Richard Smith [Fri, 28 Oct 2011 22:34:42 +0000 (22:34 +0000)]
Initial support for C++11 constexpr function invocation substitution. Using
constexpr function arguments outside of their function (passing or returning
them by reference) does not work correctly yet.
Calling constexpr function templates does not work yet, since the bodies are not
instantiated until the end of the translation unit.
Devang Patel [Fri, 28 Oct 2011 21:12:13 +0000 (21:12 +0000)]
In case of template specialization, do not try to delay emitting debug info for concrete type in -flimit-debug-info mode. This fixes some of the failures from bs15503.exp tests in gdb testsuite.
objective-c arc: type-casting of an objc pointer to
an rvalue retainable object type with life-time qualifier has no
effect and wil be diagnosed as error. // rdar://10244607
Richard Smith [Fri, 28 Oct 2011 17:51:58 +0000 (17:51 +0000)]
Reinstate r142844 (reverted in r142872) now that lvalue-to-rvalue conversions
are present in all the necessary places:
In constant expression evaluation, evaluate lvalues as lvalues and rvalues as
rvalues. Remove special case for caching reference initialization and fix a
cyclic initialization crash in the process.
Richard Smith [Fri, 28 Oct 2011 03:31:48 +0000 (03:31 +0000)]
Add (hopefully) the last missing lvalue-to-rvalue conversion. Add an assertion
to catch some future implicit lvalue-to-rvalue casts of inappropriate kinds.
Richard Trieu [Fri, 28 Oct 2011 00:41:25 +0000 (00:41 +0000)]
Fix for PR9751 to change the behavior of -Wformat warnings. If the format
string is part of the function call, then there is no difference. If the
format string is not, the warning will point to the call site and a note
will point to where the format string is.
Fix-it hints for strings are moved to the note if a note is emitted. This will
prevent changes to format strings that may be used in multiple places.
Richard Smith [Thu, 27 Oct 2011 22:11:44 +0000 (22:11 +0000)]
Fix some cases where a CK_IntegralCast was being used to convert an lvalue to an
rvalue. An assertion to catch this is in ImpCastExprToType will follow, but
vector operations currently trip over this (due to omitting the usual arithmetic
conversions). Also add an assert to catch missing lvalue-to-rvalue conversions
on the LHS of ->.
Annotate imprecise FP division with fpaccuracy metadata
The OpenCL single precision division operation is only required to
be accurate to 2.5ulp. Annotate the fdiv instruction with metadata
which signals to the backend that an imprecise divide instruction
may be used.
Ted Kremenek [Thu, 27 Oct 2011 17:55:18 +0000 (17:55 +0000)]
Move ASTUnit's handling of temporary files and the preamble file into a lazily-created static DenseMap. This DenseMap is cleared (and the files erased) via an atexit routine in the case an ASTUnit is not destroyed. Fixes <rdar://problem/10293367>.
Douglas Gregor [Thu, 27 Oct 2011 09:33:13 +0000 (09:33 +0000)]
Make the loading of information attached to an IdentifierInfo from an
AST file more lazy, so that we don't eagerly load that information for
all known identifiers each time a new AST file is loaded. The eager
reloading made some sense in the context of precompiled headers, since
very few identifiers were defined before PCH load time. With modules,
however, a huge amount of code can get parsed before we see an
@import, so laziness becomes important here.
The approach taken to make this information lazy is fairly simple:
when we load a new AST file, we mark all of the existing identifiers
as being out-of-date. Whenever we want to access information that may
come from an AST (e.g., whether the identifier has a macro definition,
or what top-level declarations have that name), we check the
out-of-date bit and, if it's set, ask the AST reader to update the
IdentifierInfo from the AST files. The update is a merge, and we now
take care to merge declarations before/after imports with declarations
from multiple imports.
The results of this optimization are fairly dramatic. On a small
application that brings in 14 non-trivial modules, this takes modules
from being > 3x slower than a "perfect" PCH file down to 30% slower
for a full rebuild. A partial rebuild (where the PCH file or modules
can be re-used) is down to 7% slower. Making the PCH file just a
little imperfect (e.g., adding two smallish modules used by a bunch of
.m files that aren't in the PCH file) tips the scales in favor of the
modules approach, with 24% faster partial rebuilds.
This is just a first step; the lazy scheme could possibly be improved
by adding versioning, so we don't search into modules we already
searched. Moreover, we'll need similar lazy schemes for all of the
other lookup data structures, such as DeclContexts.
Anna Zaks [Thu, 27 Oct 2011 00:59:23 +0000 (00:59 +0000)]
[analyzer] Make CoreEngine responsible for enqueueing Stmt Nodes.
Enqueue the nodes generated as the result of processing a statement
inside the Core Engine. This makes sure ExpEngine does not access
CoreEngine's private members and is more concise.
Objective-c: fix an ir-gen crash where objc messag returns a _Complex
value and ABI requires return slot to be passed as first
argument to message sent. // rdar://10331109
Richard Smith [Wed, 26 Oct 2011 19:06:56 +0000 (19:06 +0000)]
Pull out conversion on LHS of -> and . into its own function. This happens
implicitly in LookupMemberExpr and explicitly in cases where template
instantiation doesn't redo the lookup.
Douglas Gregor [Wed, 26 Oct 2011 17:53:41 +0000 (17:53 +0000)]
Eliminate a hang while loading a sequence of redeclarable entities. In
essence, the redeclaration chain for a class could end up in an
inconsistent state while deserializing multiple declarations in that
chain, where the circular linked list was not, in fact,
circular. Since only two redeclarations of the same entity will get
loaded when we're in this state, restore circularity when both have
been loaded. Fixes <rdar://problem/10324940> / PR11195.
Anna Zaks [Tue, 25 Oct 2011 19:57:11 +0000 (19:57 +0000)]
[analyzer] Remove getEngine() form CheckerContext
A step toward making sure that diagnostics report should only
be generated though the CheckerContext and not though BugReporter
or ExprEngine directly.
Anna Zaks [Tue, 25 Oct 2011 19:57:06 +0000 (19:57 +0000)]
[analyzer] Simplify CheckerContext
Remove dead members/parameters: ProgramState, respondsToCallback, autoTransition.
Remove addTransition method since it's the same as generateNode. Maybe we should
rename generateNode to genTransition (since a transition is always automatically
generated)?
John McCall [Tue, 25 Oct 2011 08:42:34 +0000 (08:42 +0000)]
Pull the pseudo-object stuff into its own file.
Tidy up some marginally related code just to annoy
single-purpose-commit lovers. No functionality change.
John McCall [Tue, 25 Oct 2011 07:27:56 +0000 (07:27 +0000)]
Introduce a placeholder type for "pseudo object"
expressions: expressions which refer to a logical rather
than a physical l-value, where the logical object is
actually accessed via custom getter/setter code.
A subsequent patch will generalize the AST for these
so that arbitrary "implementing" sub-expressions can
be provided.
Right now the only client is ObjC properties, but
this should be generalizable to similar language
features, e.g. Managed C++'s __property methods.
Richard Smith [Tue, 25 Oct 2011 06:33:21 +0000 (06:33 +0000)]
Don't forget the lvalue-to-rvalue conversion on the LHS when instantiating a
dependent ->, where the member being referred to is an anonymous struct or
union. This path was missed by the fix in r142890.
Douglas Gregor [Tue, 25 Oct 2011 03:44:56 +0000 (03:44 +0000)]
Check for unexpanded parameter packs in the name that guards a
Microsoft __if_exists/__if_not_exists statement. Also note that we
weren't traversing DeclarationNameInfo *at all* within the
RecursiveASTVisitor, which would be rather fatal for variadic
templates.
Douglas Gregor [Tue, 25 Oct 2011 03:07:45 +0000 (03:07 +0000)]
Make the -Wc++11-compat warnings ignored by default, so we don't break
valid C++98/03 code. However, add these warnings to -Wall, for those
who obviously already like clean code.
Douglas Gregor [Tue, 25 Oct 2011 01:33:02 +0000 (01:33 +0000)]
Implement support for dependent Microsoft __if_exists/__if_not_exists
statements. As noted in the documentation for the AST node, the
semantics of __if_exists/__if_not_exists are somewhat different from
the way Visual C++ implements them, because our parsed-template
representation can't accommodate VC++ semantics without serious
contortions. Hopefully this implementation is "good enough".
[PCH] When visiting preprocessed entities, make it possible to avoid deserializing
preprocessed entities that are #included in the range that we are interested.
This is useful when we are interested in preprocessed entities of a specific file, e.g
when we are annotating tokens. There is also an optimization where we cache the last
result of PreprocessingRecord::getPreprocessedEntitiesInRange and we re-use it if
there is a call with the same range as before.