Douglas Gregor [Sat, 20 Mar 2010 00:41:21 +0000 (00:41 +0000)]
Optimize region-of-interest based cursor walks through the
preprocessed entities by grouping preprocessed entities by file
ID. This drastically improves performance of repeated
clang_getCursor() calls local tests, although it is a bit ugly.
John McCall [Fri, 19 Mar 2010 23:29:14 +0000 (23:29 +0000)]
Change CodeGenModule to rely on the Module's symbol table instead of
shadowing it in the GlobalDeclMap. Eliminates the string-uniquing
requirement for mangled names, which should help C++ codegen times a little.
Forces us to do string lookups instead of pointer lookups, which might hurt
codegen times a little across the board. We'll see how it plays out.
Removing the string-uniquing requirement implicitly fixes any bugs like
PR6635 which arose from the fact that we had multiple uniquing tables for
different kinds of identifiers.
Douglas Gregor [Fri, 19 Mar 2010 22:13:20 +0000 (22:13 +0000)]
Remove the capture, serialization, and deserialization of comment
ranges as part of the ASTContext. This code is not and was never used,
but contributes ~250k to the size of the Cocoa.h precompiled
header.
Douglas Gregor [Fri, 19 Mar 2010 21:58:23 +0000 (21:58 +0000)]
Robustify PreprocessingRecord slightly, by only creating macro
instantiations when we have the corresponding macro definition and by
removing macro definition information from our table when the macro is
undefined.
Douglas Gregor [Fri, 19 Mar 2010 21:51:54 +0000 (21:51 +0000)]
Implement serialization and lazy deserialization of the preprocessing
record (which includes all macro instantiations and definitions). As
with all lay deserialization, this introduces a new external source
(here, an external preprocessing record source) that loads all of the
preprocessed entities prior to iterating over the entities.
The preprocessing record is an optional part of the precompiled header
that is disabled by default (enabled with
-detailed-preprocessing-record). When the preprocessor given to the
PCH writer has a preprocessing record, that record is written into the
PCH file. When the PCH reader is given a PCH file that contains a
preprocessing record, it will be lazily loaded (which, effectively,
implicitly adds -detailed-preprocessing-record). This is the first
case where we have sections of the precompiled header that are
added/removed based on a compilation flag, which is
unfortunate. However, this data consumes ~550k in the PCH file for
Cocoa.h (out of ~9.9MB), and there is a non-trivial cost to gathering
this detailed preprocessing information, so it's too expensive to turn
on by default. In the future, we should investigate a better encoding
of this information.
Daniel Dunbar [Fri, 19 Mar 2010 19:44:04 +0000 (19:44 +0000)]
clang -cc1: Kill off -empty-input only, and replace with -init-only which is an
actual action.
- This is easier to use, and more reliable for timing the thing this was
actually meant to be useful for.
Douglas Gregor [Fri, 19 Mar 2010 17:12:43 +0000 (17:12 +0000)]
Make the preprocessing record a PPCallbacks subclass itself,
eliminating the extra PopulatePreprocessingRecord object. This will
become useful once we start writing the preprocessing record to
precompiled headers.
John McCall [Fri, 19 Mar 2010 07:35:19 +0000 (07:35 +0000)]
Remember the "found declaration" for an overload candidate, which is the
entity (if applicable) which was actually looked up. If a candidate was found
via a using declaration, this is the UsingShadowDecl; otherwise, if
the candidate is template specialization, this is the template; otherwise,
this is the function.
The point of this exercise is that "found declarations" are the entities
we do access control for, not their underlying declarations. Broadly speaking,
this patch fixes access control for using declarations.
There is a *lot* of redundant code calling into the overload-resolution APIs;
we really ought to clean that up.
Douglas Gregor [Fri, 19 Mar 2010 06:12:06 +0000 (06:12 +0000)]
Fix a longstanding (but previously unknown) bug in the lazy
deserialization of precompiled headers, where the deserialization of
the source location entry for a buffer (e.g., macro instantiation
scratch space) would overwrite a one-element FileID cache in the
source manager. When tickled at the wrong time, we would return the
wrong decomposed source location and eventually cause c-index-test to
crash.
Found by dumb luck. It's amazing this hasn't shown up before.
Douglas Gregor [Fri, 19 Mar 2010 05:22:59 +0000 (05:22 +0000)]
Visit preprocessing elements (macro instantiations and macro
definitions) as part of the translation unit, so that normal
visitation, token-annotation, and cursor-at retrieval all see
preprocessing elements.
Douglas Gregor [Fri, 19 Mar 2010 00:18:31 +0000 (00:18 +0000)]
Visit preprocessing elements (macro instantiations and macro
definitions) as part of the translation unit, so that normal
visitation, token-annotation, and cursor-at retrieval all see
preprocessing elements.
John McCall [Thu, 18 Mar 2010 23:49:19 +0000 (23:49 +0000)]
When elevating access along an inheritance path, initialize the computed
access to the (elevated) access of the accessed declaration, if applicable,
rather than plunking that access onto the end after we've calculated the
inheritance access.
Also, being a friend of a derived class gives you public access to its
members (subject to later modification by further inheritance); it does
not simply ignore a single location of restricted inheritance.
Also, when computing the best unprivileged path to a subobject, preserve
the information that the worst path might be AS_none (forbidden) rather
than a minimum of AS_private.
Douglas Gregor [Thu, 18 Mar 2010 23:46:43 +0000 (23:46 +0000)]
For debug information, get the main file name from the source manager
rather than from the -main-file-name flag, since the source manager
has proper path information. Fixes <rdar://problem/7769538>.
Ted Kremenek [Thu, 18 Mar 2010 21:23:08 +0000 (21:23 +0000)]
Make PredefinedExpr::ComputeName() more robust to incorrect
code when we are printing the name of an Objective-C method
whose class has not been declared. Fixes <rdar://problem/7495713>.
Douglas Gregor [Thu, 18 Mar 2010 18:23:03 +0000 (18:23 +0000)]
Explicitly link macro instantiations to macro definitions in the
preprocessing record. Use that link with clang_getCursorReferenced()
and clang_getCursorDefinition() to match instantiations of a macro to
the definition of the macro.
Douglas Gregor [Thu, 18 Mar 2010 17:52:52 +0000 (17:52 +0000)]
Introduce the notion of a "preprocessing record", which keeps track of
the macro definitions and macro instantiations that are found
during preprocessing. Preprocessing records are *not* generated by
default; rather, we provide a PPCallbacks subclass that hooks into the
existing callback mechanism to record this activity.
The only client of preprocessing records is CIndex, which keeps track
of macro definitions and instantations so that they can be exposed via
cursors. At present, only token annotation uses these facilities, and
only for macro instantiations; both will change in the near
future. However, with this change, token annotation properly annotates
macro instantiations that do not produce any tokens and instantiations
of macros that are later undef'd, improving our consistency.
Preprocessing directives that are not macro definitions are still
handled by clang_annotateTokens() via re-lexing, so that we don't have
to track every preprocessing directive in the preprocessing record.
Performance impact of preprocessing records is still TBD, although it
is limited to CIndex and therefore out of the path of the main compiler.
John McCall [Thu, 18 Mar 2010 08:19:33 +0000 (08:19 +0000)]
from code inspection, we were treating placement news with one argument as
non-placement news when selecting the corresponding operator delete; this is
fixed.
Access and ambiguity control for calls to operator new and delete. Also AFAICT
Ted Kremenek [Thu, 18 Mar 2010 01:22:39 +0000 (01:22 +0000)]
Tweak dead stores checker to not emit a warning when initialization
a scalar variable with a scalar parameter. This is a
form of defensive programming. If the variable is unused,
it will be caused by -Wunused-variable.
Douglas Gregor [Thu, 18 Mar 2010 00:42:48 +0000 (00:42 +0000)]
Experimental stab at using relexing to identify preprocessor
directives while annotating tokens in CIndex. This functionality
should probably be factored out of this routine, but we're not there
yet.
John McCall [Wed, 17 Mar 2010 19:25:57 +0000 (19:25 +0000)]
ActOnTagDefinitionError is supposed to 'unwind' ActOnTagStartDefinition, not
ActOnStartCXXMemberDeclaration. We haven't started the field collector on this
class yet, so don't stop it. Fixes a crash in the VS buildbot and a memory error
on all the others.
Douglas Gregor [Wed, 17 Mar 2010 18:46:59 +0000 (18:46 +0000)]
Reduce the default alignment for ASTContext and Stmt/Expr allocation
from 16 bytes to 8 bytes, since we don't ever use those low 4
bits. Should save some storage.
Douglas Gregor [Wed, 17 Mar 2010 16:03:44 +0000 (16:03 +0000)]
Remove warning about shadowing a built-in; built-ins aren't actually
considered to be a part of the translation unit unless they're named
in a way that brings them into existence.
Douglas Gregor [Wed, 17 Mar 2010 15:30:15 +0000 (15:30 +0000)]
Use a simple diagnostic (file modified) when we detect that a file has
changed, rather than trying to point out how it changed. The "why"
doesn't matter.
Douglas Gregor [Tue, 16 Mar 2010 22:53:51 +0000 (22:53 +0000)]
Teach SourceManager's content cache to keep track of whether its
buffer was invalid when it was created, and use that bit to always set
the "Invalid" flag according to whether the buffer is invalid. This
ensures that all accesses to an invalid buffer are marked invalid,
improving recovery.
Douglas Gregor [Tue, 16 Mar 2010 20:01:30 +0000 (20:01 +0000)]
Audit all getBuffer() callers (for both the FullSourceLoc and
SourceManager versions), updating those callers that need to recover
gracefully from failure.
Douglas Gregor [Tue, 16 Mar 2010 16:35:32 +0000 (16:35 +0000)]
Fix header-search problems with precompiled headers, where the
presence or absence of header map arguments when using the precompiled
header would cause Clang to get confused about which headers had
already been included/imported, along with their controlling
macros. The fundamental problem is that the serialization of the
header search information was relying on the UIDs of FileEntry objects
at PCH generation time and PCH load time to be equivalent, which
effectively means that we had to probe the same files in the same
order. Differing header map arguments caused an extra FileEntry
lookup, but it's easy to imagine other minor command-line arguments
triggering this problem.
Header-search information is now encoded along with the
source-location entry for a file, so that we register information
about a file's properties as a header at the same time we create the
FileEntry for that file.
Zhongxing Xu [Tue, 16 Mar 2010 13:14:16 +0000 (13:14 +0000)]
Add VisitCXXContructExpr logic to the analyzer. This still has not fully worked
since RemoveDeadBinding mistakenly remove the binding to CXXThisRegion.