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.
Douglas Gregor [Tue, 16 Mar 2010 05:20:39 +0000 (05:20 +0000)]
Introduce optional "Invalid" parameters to routines that invoke the
SourceManager's getBuffer() and, therefore, could fail, along with
Preprocessor::getSpelling(). Use the Invalid parameters in the literal
parsers (string, floating point, integral, character) to make them
robust against errors that stem from, e.g., PCH files that are not
consistent with the underlying file system.
I still need to audit every use caller to all of these routines, to
determine which ones need specific handling of error conditions.
Douglas Gregor [Mon, 15 Mar 2010 22:54:52 +0000 (22:54 +0000)]
Introduce a new BufferResult class to act as the return type of
SourceManager's getBuffer() (and similar) operations. This abstract
can be used to force callers to cope with errors in getBuffer(), such
as missing files and changed files. Fix a bunch of callers to use the
new interface.
Add some very basic checks for file consistency (file size,
modification time) into ContentCache::getBuffer(), although these
checks don't help much until we've updated the main callers (e.g.,
SourceManager::getSpelling()).
Ted Kremenek [Mon, 15 Mar 2010 20:30:07 +0000 (20:30 +0000)]
Move method FindPropertyVisibleInPrimaryClass() from ObjCContainerDecl to ObjCInterfaceDecl.
Also change this method to lookup property declarations using DeclContext::lookup().
Ted Kremenek [Mon, 15 Mar 2010 18:47:25 +0000 (18:47 +0000)]
Correctly determine if the @property has been previously declared. If
a property has the same name as the ivar it wraps then the old logic
wouldn't find the previous property declaration.
Douglas Gregor [Mon, 15 Mar 2010 15:26:48 +0000 (15:26 +0000)]
During C++ name lookup, use DeclContext::Equals() rather than
comparing DeclContext pointers, to avoid having to remember to call
getPrimaryContext() everywhere. This is the last part PR6594.
Douglas Gregor [Mon, 15 Mar 2010 14:33:29 +0000 (14:33 +0000)]
Implement C++ [temp.local]p8, which specifies that a template
parameter hides a namespace-scope declararion with the same name in an
out-of-line definition of a template. The lookup requires a strange
interleaving of lexical and semantic scopes (go C++), which I have not
yet handled in the typo correction/code completion path.
John McCall [Mon, 15 Mar 2010 10:12:16 +0000 (10:12 +0000)]
Remember declaration scope qualifiers in the AST. Imposes no memory overhead
on unqualified declarations.
Patch by Enea Zaffanella! Minimal adjustments: allocate the ExtInfo nodes
with the ASTContext and delete them during Destroy(). I audited a bunch of
Destroy methods at the same time, to ensure that the correct teardown was
being done.