Daniel Dunbar [Sun, 18 Oct 2009 02:09:17 +0000 (02:09 +0000)]
Simplify HandleFormatAttr.
- I have this crazy dream that one day someone will invent a miraculous tool so
that developers, instead of hand optimizing their source code to obscure its
intent and decrease its maleability, will instead write what they mean, and
this strange and wonderful tool -- which I imagine would be called something
fancy sounding like "an optimizing compiler" -- will make their code fast
*for* them. With all the saved time, developers could maybe even focus on
making the magic "optimizing compiler" better!!
- No intended functionality change, all though I expect the universe to mock me
for snarkiness.
John McCall [Sun, 18 Oct 2009 01:05:36 +0000 (01:05 +0000)]
Clone the full Type hierarchy into the TypeLoc hierarchy. Normalize
TypeLoc class names to be $(Type classname)Loc. Rewrite the visitor.
Provide skeleton implementations for all the new TypeLocs.
Handle all cases in PCH. Handle a few more cases when inserting
location information in SemaType.
It should be extremely straightforward to add new location information
to existing TypeLoc objects now.
Douglas Gregor [Sat, 17 Oct 2009 21:40:42 +0000 (21:40 +0000)]
When type-checking a C++ "new" expression, don't type-check the actual
initialization if any of the constructor/initialization arguments are
type-dependent. Fixes PR5224.
Sebastian Redl [Sat, 17 Oct 2009 21:12:09 +0000 (21:12 +0000)]
When resolving the address of an overloaded function or function template, mark the result as referenced.
The most important effect of this is that function templates only referenced by address expressions now get instantiated. This, in turn, means that Hello World compiles with the Apache stdcxx library even when using endl.
Sebastian Redl [Sat, 17 Oct 2009 20:50:27 +0000 (20:50 +0000)]
Don't add implicit casts of explicit address-taking of overloaded functions.
Taking the address of an overloaded function with an explicit address-of operator wrapped the operator in an implicit cast that added yet another pointer level, leaving us with a corrupted AST, which crashed CodeGen in the test case I've added. Fix this by making FixOverloadedFunctionReference return whether there was an address-of operator and not adding the implicit cast in that case.
Sebastian Redl [Sat, 17 Oct 2009 19:37:06 +0000 (19:37 +0000)]
In some dependent contexts, incomplete array types persist into FinalizeDeclaratorGroup. Don't require them to have a complete type. This allows us to compile Hello World with the Apache stdcxx library. If you don't use endl, it even links and runs.
Daniel Dunbar [Sat, 17 Oct 2009 09:38:57 +0000 (09:38 +0000)]
Remove a FIXME that doesn't belong, there are numerous other places that use
alignment in bits in clang. If we really want to fix this, it should be a bugzilla.
Zhongxing Xu [Sat, 17 Oct 2009 08:39:24 +0000 (08:39 +0000)]
Per discussion with Ted, the 'FromSuper'/'FromSub' logic is invalid. Simplify
the code to standard worklist algorithm. Always add both sub and super
regions of live regions.
Daniel Dunbar [Sat, 17 Oct 2009 06:13:04 +0000 (06:13 +0000)]
Don't crash when dumping pretty stack traces, if the current tok is an
annotation token.
- I'm not sure what the best thing to print is, for now we just print the token
location and 'at annotation token'.
Daniel Dunbar [Sat, 17 Oct 2009 03:28:48 +0000 (03:28 +0000)]
Add IdentiferInfo::getNameStr() -> StringRef.
Also, add getNameStart as a synonym for getName(). getName() is now deprecated,
when all clients are updated then getNameStr() should be renamed to
getName(). PR5218.
Douglas Gregor [Sat, 17 Oct 2009 00:13:19 +0000 (00:13 +0000)]
Merge the "types" and "declarations" blocks in the precompiled header
format, so that we don't end up with multiple declaration and types
blocks. Also, fix a few obscure bugs with PCH loading and generation:
- If the DeclIDs DenseMap reallocates while we are writing a
declaration (due to recursively writing other declarations), we
could end up writing a bad ID to ExternalDefinitions.
- When loading an ArrayLoc (part of DeclaratorInfo), we need to set
the size expression to NULL if no size expression was provided.
PCH -> AST rewriting is still partly broken, unfortunately.
Douglas Gregor [Fri, 16 Oct 2009 22:46:09 +0000 (22:46 +0000)]
While writing source-location entries to a PCH file, go through an
interface that can load those source-location entries on demand (from
another PCH file).
John McCall [Fri, 16 Oct 2009 22:31:57 +0000 (22:31 +0000)]
Allow TypeLocs to be fully initialized with a single SourceLocation. This
will be the keystone of converting existing rewrites to be rewrites on TypeLocs.
Use VisibleQuals to control setting of Volatile/Restrict qualifiers on
candidate types in BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants
further trimming the overload candidate set.
Douglas Gregor [Fri, 16 Oct 2009 21:24:31 +0000 (21:24 +0000)]
Make CIndex and c-index-test a little bit more robust. The only
substantive change is that clang_getCursorSource() now returns the
file in which a macro was instantiated when the cursor points into a
macro instantiation, rather than crashing.
Ted Kremenek [Fri, 16 Oct 2009 20:46:24 +0000 (20:46 +0000)]
Fix static analyzer crash due to recently add symbolic-value constant folding. The issue was falsely
converting the constant value of the LHS of a '<<'/'>>' operation to the same APSInt value of the
RHS.
Douglas Gregor [Fri, 16 Oct 2009 20:01:17 +0000 (20:01 +0000)]
Keep track of whether declararions were loaded from a precompiled
header or not via a new "PCHLevel" field in Decl. We currently use
this information to help CIndex filter out declarations that came from
a precompiled header (rather than from an AST file). Further down the
road, it can be used to help implement multi-level precompiled
headers.
Douglas Gregor [Fri, 16 Oct 2009 18:18:30 +0000 (18:18 +0000)]
Add support for a chain of stat caches in the FileManager, rather than
only supporting a single stat cache. The immediate benefit of this
change is that we can now generate a PCH/AST file when including
another PCH file; in the future, the chain of stat caches will likely
be useful with multiple levels of PCH files.
John McCall [Fri, 16 Oct 2009 00:14:28 +0000 (00:14 +0000)]
Remove the ConstantArrayType subtypes. This information is preserved in the
TypeLoc records for declarations; it should not be necessary to represent it
directly in the type system.
Please complain if you were using these classes and feel you can't replicate
previous functionality using the TypeLoc API.
Douglas Gregor [Thu, 15 Oct 2009 22:53:21 +0000 (22:53 +0000)]
Make the remaining explicit-instantiation semantic action use
CheckSpecializationInstantiationRedecl to check for
redeclarations/instantiations. Also fixes a longstanding issue where
our explicit-instantiation location information wasn't as good as it
could have been.
John McCall [Thu, 15 Oct 2009 22:37:38 +0000 (22:37 +0000)]
ConcreteTypeLoc subclasses which call getInnerTypeLoc() should get a
compile-time error now; moreover, remove the need for an explicit hasInnerType()
call. Thanks to Doug Gregor for the metaprogramming approach.
Daniel Dunbar [Thu, 15 Oct 2009 20:02:44 +0000 (20:02 +0000)]
Driver: Default to using PTH for C++ precompiled header support, PCH for C++
isn't implemented yet.
- <rdar://problem/7297571> Clang should use pretokenized headers for C++ PCH
files
Douglas Gregor [Thu, 15 Oct 2009 17:21:20 +0000 (17:21 +0000)]
Simplify checking of explicit template specialization/explicit
instantiation redeclaration semantics for function template
specializations and member functions of class template
specializations. Also, record the point of instantiation for
explicit-instantiated functions and static data members.
Apply heuristics to cut back on number of candidate
sets of builtin operators. Currently, it is applied
to '++' and '->*' operators. I need to apply it to others
as well. Also, heuristics need be applied to
BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants.
This is WIP.
Douglas Gregor [Thu, 15 Oct 2009 15:54:05 +0000 (15:54 +0000)]
Check the interactions between explicit instantiations and template
specializations. Work in progress; there's more cleanup required to
actually use the new CheckSpecializationInstantiationRedecl checker
uniformly.
Douglas Gregor [Thu, 15 Oct 2009 14:05:49 +0000 (14:05 +0000)]
Diagnose explicit instantiations of function templates and member
functions/static data members of class template specializations that
do not have definitions. This is the latter part of [temp.explicit]p4;
the former part still needs more testing.
Douglas Gregor [Thu, 15 Oct 2009 12:53:22 +0000 (12:53 +0000)]
More explicit template instantiation. Now we're checking for more
cases where an explicit instantiation requires a definition; the
remainder of these checks will come with the implementation of
paragraph 4 of [temp.explicit].