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.
Douglas Gregor [Mon, 24 Oct 2011 22:31:10 +0000 (22:31 +0000)]
Rework Microsoft __if_exists/__if_not_exists parsing and semantic
analysis to separate dependent names from non-dependent names. For
dependent names, we'll behave differently from Visual C++:
- For __if_exists/__if_not_exists at class scope, we'll just warn
and then ignore them.
- For __if_exists/__if_not_exists in statements, we'll treat the
inner statement as a compound statement, which we only instantiate
in templates where the dependent name (after instantiation)
exists. This behavior is different from VC++, but it's as close as
we can get without encroaching ridiculousness.
The latter part (dependent statements) is not yet implemented.
Douglas Gregor [Mon, 24 Oct 2011 22:24:50 +0000 (22:24 +0000)]
When we perform a lookup for a dependent name that is a member of an
unknown specialization, treat this the same way as if the name were
not found in the current instantiation. No actual functionality
change, since apparently nothing depends on this.
Richard Smith [Mon, 24 Oct 2011 21:07:08 +0000 (21:07 +0000)]
Constant expression evaluation: evaluate lvalues as lvalues, and rvalues as
rvalues, as C++11 constant evaluation semantics require. DeclRefs referring to
references can now use the normal initialization-caching codepath, which
incidentally fixes a crash in cyclic initialization of references.
Richard Smith [Mon, 24 Oct 2011 18:26:35 +0000 (18:26 +0000)]
In accordance with the C89, C99 and C++98 standards, ICEs can only contain
floating-point literals if they are the immediate operands of casts.
ImplicitCastExpr is not a cast in the language-standards sense.
Anna Zaks [Mon, 24 Oct 2011 18:26:19 +0000 (18:26 +0000)]
[analyzer] Convert ExprEngine::visit() to use short lived builders.
This commit removes the major functional dependency on the ExprEngine::Builder
member variable.
In some cases the code became more verbose. Particularly, we call takeNodes()
and addNodes() to move responsibility for the nodes from one builder to another.
This will get simplified later on.
Anna Zaks [Mon, 24 Oct 2011 18:26:03 +0000 (18:26 +0000)]
[analyzer] Convert VisitUnaryOperator to use short lived Node builders
To convert iteratively, we take the nodes the local builder will
process from the from the global builder and add the generated nodes
after the short lived builder is done. PureStmtNodeBuilder is the
one we should eventually use everywhere. Added Stmt index and Builder
context as ExprEngine globals. To avoid passing them around.
Anna Zaks [Mon, 24 Oct 2011 18:25:58 +0000 (18:25 +0000)]
[analyzer] Use a temporary builder in CheckerContext.
First step toward removing the global Stmt builder. Added several transitional methods (like takeNodes/addNodes).
+ Stop early if the set of exploded nodes for the next iteration is empty.
Anna Zaks [Mon, 24 Oct 2011 18:25:53 +0000 (18:25 +0000)]
[analyzer] Pass external Dst set to NodeBuilder
This moves the responsibility for storing the output node set from the
builder to the clients. The builder is just responsible for transforming
an input set into the output set: {SrcSet/SrcNode} -> {Frontier}.
Chandler Carruth [Mon, 24 Oct 2011 01:47:37 +0000 (01:47 +0000)]
Actually rename the file AnalysisContext.cpp -> AnalysisDeclContext.cpp
to match the CMakeLists.txt change in r142782; this should fix the CMake
build.
Richard Smith [Sat, 22 Oct 2011 21:10:00 +0000 (21:10 +0000)]
Refactor vector constant expression evaluation to return bool like all the other
const expression evaluation subclasses, and remove some APValue copying and
malloc traffic in the process.
NAKAMURA Takumi [Sat, 22 Oct 2011 11:28:32 +0000 (11:28 +0000)]
test/Driver/debug.c: Mark this as "REQUIRES: shell".
Former RUN line does not make sense on Win32 hosts.
Win32 hosts would not be expected to set appropriate $PWD.
Latter RUN line might be made valid if PathV2::is_absolute("/foo") would be true. Unfortunately, "/foo" should not be treated as absolute path on Win32.
FYI, on mingw32 with MSYS bash (it has 'shell' feature);
Former) $PWD is set as "X:/hogehoge/test/Driver"
Latter) PWD=/foo sets "X:/root/to/msys/foo" to $PWD.
Ted Kremenek [Sat, 22 Oct 2011 02:37:33 +0000 (02:37 +0000)]
Only emit implicit constant conversion truncation warnings in reachable code. Apparently this is what GCC does, and some code depends on this. Fixes <rdar://problem/10321089>.
objc: private methods can have their attributes, no diagnostic is required.
None private methods if their implementation have attribute, they must exactly
match those in their declarations. // rdar://10271563
[PCH] When serializing Stmts, keep track of when sub statements are referenced again and
in such a case just write out a reference of a previously serialized Stmt, instead
of serializing it all over again.
This saves memory + space + [de]serializing time, and avoids blowing up memory
with pathological cases. rdar://10293911
c++: support gcc's application of weak attribute on
class declaration which forces any such class and any
class that inherits from such a class to have their
typeinfo symbols be marked as weak.
// rdar://10246395
A test/CodeGenCXX/weak-extern-typeinfo.cpp
M lib/Sema/SemaDeclCXX.cpp
M lib/Sema/SemaDeclAttr.cpp
M lib/CodeGen/CGRTTI.cpp
Sean Callanan [Fri, 21 Oct 2011 16:15:18 +0000 (16:15 +0000)]
Added documentation for the recently-added
addDecl() and makeDeclVisibleInContextInternal()
functions, and made the latter private since it
does not and should not have external clients.
Douglas Gregor [Fri, 21 Oct 2011 15:47:52 +0000 (15:47 +0000)]
When performing name lookup for the previous declaration of a field,
be sure to consider all of the possible lookup results. We were
assert()'ing (but behaving correctly) for unresolved values. Fixes
PR11134 / <rdar://problem/10290422>.
Douglas Gregor [Fri, 21 Oct 2011 03:57:52 +0000 (03:57 +0000)]
Treat the Microsoft/Borland keyword "__except" as a context-sensitive
keyword, because both libstdc++ and libc++ use "__except" as an
identifier. Fixes <rdar://problem/10322555>.
Sean Callanan [Fri, 21 Oct 2011 02:57:43 +0000 (02:57 +0000)]
I added a new function to DeclContext called
addDeclInternal(). This function suppresses any
calls to FindExternalVisibleDeclsByName() while
a Decl is added to a DeclContext. This behavior
is required for the ASTImporter, because in the
case of the LLDB client the ASTImporter would be
called recursively to import the visible decls,
which leads to assertions because the recursive
call is seeing partially-formed types.
I also modified the ASTImporter to use
addDeclInternal() in all places where it would
otherwise use addDecl(). This fix should not
affect the rest of Clang, passes Clang's
testsuite, and fixes several serious LLDB bugs.
Nick Lewycky [Fri, 21 Oct 2011 02:32:14 +0000 (02:32 +0000)]
Take DW_AT_comp_dir from $PWD when it's present and starts with a '/'. This is
closer to what GCC does, except that GCC also checks that the inodes for $PWD
and '.' match.
Richard Smith [Thu, 20 Oct 2011 21:42:12 +0000 (21:42 +0000)]
Add -Wc++98-compat diagnostics for jumps which bypass initialization of non-POD
but trivially constructible and destructible variables in C++11 mode. Also
incidentally improve the precision of the wording for jump diagnostics in C++98
mode.