Commit Graph

53 Commits

Author SHA1 Message Date
Benjamin Kramer 7ec12c928a Revert my patches which removed Diagnostic.h includes by moving some operator overloads out of line.
This seems to negatively affect compile time onsome ObjC tests
(which use a lot of partial diagnostics I assume). I have to come
up with a way to keep them inline without including Diagnostic.h
everywhere. Now adding a new diagnostic requires a full rebuild
of e.g. the static analyzer which doesn't even use those diagnostics.

This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99.
This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789.
This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7.
This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f.
This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5.

llvm-svn: 150006
2012-02-07 22:29:24 +00:00
Benjamin Kramer 3307c508c9 Move various diagnostic operator<< overloads out of line and remove includes of Diagnostic.h.
Fix all the files that depended on transitive includes of Diagnostic.h.
With this patch in place changing a diagnostic no longer requires a full rebuild of the StaticAnalyzer.

llvm-svn: 149781
2012-02-04 12:31:12 +00:00
David Blaikie e4d798f078 More dead code removal (using -Wunreachable-code)
llvm-svn: 148577
2012-01-20 21:50:17 +00:00
Benjamin Kramer b89514a9b8 Change operator<< for raw_ostream and NamedDecl to take a reference instead of a pointer.
Passing a pointer was a bad idea as it collides with the overload for void*.

llvm-svn: 141971
2011-10-14 18:45:37 +00:00
David Blaikie aa347f9392 Removing a bunch of dead returns/breaks after llvm_unreachables.
llvm-svn: 140407
2011-09-23 20:26:49 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Douglas Gregor 678d76c026 Introduce the notion of instantiation dependence into Clang's AST. A
type/expression/template argument/etc. is instantiation-dependent if
it somehow involves a template parameter, even if it doesn't meet the
requirements for the more common kinds of dependence (dependent type,
type-dependent expression, value-dependent expression).

When we see an instantiation-dependent type, we know we always need to
perform substitution into that instantiation-dependent type. This
keeps us from short-circuiting evaluation in places where we
shouldn't, and lets us properly implement C++0x [temp.type]p2.

In theory, this would also allow us to properly mangle
instantiation-dependent-but-not-dependent decltype types per the
Itanium C++ ABI, but we aren't quite there because we still mangle
based on the canonical type in cases like, e.g.,

  template<unsigned> struct A { };
  template<typename T>
    void f(A<sizeof(sizeof(decltype(T() + T())))>) { }
  template void f<int>(A<sizeof(sizeof(int))>);

and therefore get the wrong answer.

llvm-svn: 134225
2011-07-01 01:22:09 +00:00
Douglas Gregor af2a6ae429 Selector::getIdentifierInfoForSlot() can return NULL values, a fact
that was ignored in a few places (most notably, code
completion). Introduce Selector::getNameForSlot() for the common case
where we only care about the name. Audit all uses of
getIdentifierInfoForSlot(), switching many over to getNameForSlot(),
fixing a few crashers.

Fixed <rdar://problem/8939352>, a code-completion crasher.

llvm-svn: 125977
2011-02-18 22:29:55 +00:00
Jay Foad 39c7980772 PR3558: mark "logically const" accessor methods in ASTContext as const,
and mark the fields they use as mutable. This allows us to remove a few
const_casts.

llvm-svn: 123314
2011-01-12 09:06:06 +00:00
Chandler Carruth 2b59fbe719 Silence GCC warning about control reaching the end of the function and explicitly mark that all cases are handled.
llvm-svn: 121855
2010-12-15 07:29:18 +00:00
Douglas Gregor a6e053e61a Variadic templates: extend the Expr class with a bit that specifies
whether the expression contains an unexpanded parameter pack, in the
same vein as the changes to the Type hierarchy. Compute this bit
within all of the Expr subclasses.

This change required a bunch of reshuffling of dependency
calculations, mainly to consolidate them inside the constructors and
to fuse multiple loops that iterate over arguments to determine type
dependence, value dependence, and (now) containment of unexpanded
parameter packs.

Again, testing is painfully sparse, because all of the diagnostics
will change and it is more important to test the to-be-written visitor
that collects unexpanded parameter packs.

llvm-svn: 121831
2010-12-15 01:34:56 +00:00
Abramo Bagnara d6d2f18905 Added locations and type source info for DeclarationName.
llvm-svn: 110860
2010-08-11 22:01:17 +00:00
Douglas Gregor 5b11d49a7c Make ASTContext always use the BumpPtrAllocator.
llvm-svn: 109375
2010-07-25 17:53:33 +00:00
Ted Kremenek 7e550caf4e Allocate most of DeclarationNamesTable using ASTContext's allcocator. The only things that
aren't allocated this way are the internal FoldingSets.

llvm-svn: 103429
2010-05-10 20:56:10 +00:00
Ted Kremenek 6aead3a051 Start converting pieces of DeclarationNameTable to be allocated using ASTContext's allocator.
While DeclarationNameTable doesn't leak, it uses 'malloc' too often.  Start with having
'CXXLiteralOperatorNames' allocated using ASTContext's allocator and add a 'DoDestroy()' method
to DeclarationNameTable that is called by ~ASTContext.

llvm-svn: 103426
2010-05-10 20:40:08 +00:00
Benjamin Kramer 95c7c427aa Add printName to DeclarationName which prints the human-readable name on a
raw_ostream. Use it in getAsString and NamedDecl's raw_ostream operator.

llvm-svn: 101633
2010-04-17 09:56:45 +00:00
John McCall ef3057c419 Switch the standard DeclarationName comparator to be a tri-valued comparator.
Use that while fixing a nasty misuse of qsort in vtable codegen which, somehow,
has not actually caused a crash.

llvm-svn: 96062
2010-02-13 01:04:05 +00:00
Alexis Hunt c88db06565 Implement semantic checking for C++ literal operators.
This now rejects literal operators that don't meet the requirements.
Templates are not yet checked for.

llvm-svn: 93315
2010-01-13 09:01:02 +00:00
Douglas Gregor ea0a0a9b3f Implement name lookup for conversion function template specializations
(C++ [temp.mem]p5-6), which involves template argument deduction based
on the type named, e.g., given

  struct X { template<typename T> operator T*(); } x;

when we call

  x.operator int*();

we perform template argument deduction to determine that T=int. This
template argument deduction is needed for template specialization and
explicit instantiation, e.g.,

  template<> X::operator float*() { /* ... */ }

and when calling or otherwise naming a conversion function (as in the
first example). 

This fixes PR5742 and PR5762, although there's some remaining ugliness
that's causing out-of-line definitions of conversion function
templates to fail. I'll look into that separately.

llvm-svn: 93162
2010-01-11 18:40:55 +00:00
Nuno Lopes cfca1f0dc1 move a few more symbols to .rodata/.data.rel.ro
llvm-svn: 92012
2009-12-23 17:49:57 +00:00
Nuno Lopes 221c1fd63e spread 'const' love to some variables. this considerably reduces the amount of dirty data around.
llvm-svn: 91002
2009-12-10 00:07:02 +00:00
Alexis Hunt 3d221f2fce Add DeclarationName support for C++0x operator literals. They should now work as
function names outside of templates - they'll probably cause some damage there as
they're largely untested.

llvm-svn: 90064
2009-11-29 07:34:05 +00:00
Chandler Carruth 2496fe14ec Fix a missing include from r88876.
llvm-svn: 88879
2009-11-15 23:10:57 +00:00
Anders Carlsson 1b69be2a8f Add DeclarationName::dump().
llvm-svn: 88876
2009-11-15 22:30:43 +00:00
Douglas Gregor b082bab69e Give DeclarationName's operator< a more predictable, useful ordering
llvm-svn: 86055
2009-11-04 22:24:30 +00:00
Daniel Dunbar 07d0785dbb PR5218: Replace IdentifierInfo::getName with StringRef version, now that clients
are updated.

llvm-svn: 84447
2009-10-18 21:17:35 +00:00
Daniel Dunbar 70e7eadd15 Move misc clients to IdentifierInfo StringRef API.
- strcmp -> ==
 - OS.write(II->getName() ...) -> OS << II->getNameStr()
 - Avoid std::string concatenation
 - Use getNameStr().str() when an std::string is really needed.

llvm-svn: 84437
2009-10-18 20:26:27 +00:00
Douglas Gregor 4505315726 Write the preprocessor block after we write out types + declarations,
so that we catch any macros used within the declarations and types. 

Also, properly store a NULL selector.

llvm-svn: 84334
2009-10-17 17:25:45 +00:00
John McCall 8ccfcb51ee Refactor the representation of qualifiers to bring ExtQualType out of the
Type hierarchy.  Demote 'volatile' to extended-qualifier status.  Audit our
use of qualifiers and fix a few places that weren't dealing with qualifiers
quite right;  many more remain.

llvm-svn: 82705
2009-09-24 19:53:00 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Douglas Gregor 2211d345d2 Introduce the canonical type smart pointers, and use them in a few places to
tighten up the static type system.

llvm-svn: 78164
2009-08-05 05:36:45 +00:00
Ted Kremenek c23c7e6a51 Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.

llvm-svn: 77510
2009-07-29 21:53:49 +00:00
Ted Kremenek 8a286fbdb9 Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.

llvm-svn: 76193
2009-07-17 17:50:17 +00:00
Ted Kremenek b825c0ddc5 Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
llvm-svn: 76139
2009-07-17 01:20:38 +00:00
Douglas Gregor 8d2ad873e7 Make sure that we use the canonical type for the names of instantiated
constructors and destructors. This is a requirement of
DeclarationNameTable::getCXXSpecialName that we weren't assert()'ing,
so it should have been caught much earlier :(

Big thanks to Anders for the test case.

llvm-svn: 71895
2009-05-15 21:18:27 +00:00
Douglas Gregor 512b077803 PCH support for all of the predefined Objective-C types, such as id,
SEL, Class, Protocol, CFConstantString, and
__objcFastEnumerationState. With this, we can now run the Objective-C
methods and properties PCH tests.

llvm-svn: 69932
2009-04-23 22:29:11 +00:00
Douglas Gregor 48db39dc90 Remove the serialization code that predates precompiled
headers. Future approaches to (de-)serializing ASTs will be based on
the PCH infrastructure.

llvm-svn: 69828
2009-04-22 21:45:53 +00:00
Chris Lattner 7d5608dd72 add an assertion for unreachable code.
llvm-svn: 67432
2009-03-21 06:40:50 +00:00
Ted Kremenek d0fa573a7d Remove dead DeclarationName constructors that involving knowing about the
internal implementation of Selector.

llvm-svn: 66996
2009-03-14 00:27:40 +00:00
Chris Lattner 8ba22471a2 fix long lines.
llvm-svn: 64684
2009-02-16 22:33:34 +00:00
Douglas Gregor 889ceb752d Semantic analysis, ASTs, and unqualified name lookup support for C++
using directives, from Piotr Rak!

llvm-svn: 63646
2009-02-03 19:21:40 +00:00
Douglas Gregor f399ef43c7 Make sure we don't name a constructor or destructor with a qualified
type. It leads to very weird errors.

llvm-svn: 62124
2009-01-13 00:11:19 +00:00
Nuno Lopes 3167976f77 dont call iterator::end() on every cycle and dont read already-deleted memory
llvm-svn: 61015
2008-12-14 21:53:25 +00:00
Nuno Lopes 13c2c1eeca minor WS fix for the previous commit
llvm-svn: 61008
2008-12-14 17:44:24 +00:00
Nuno Lopes 127adb4462 fix leakage of CXXSpecialName objects in DeclarationNameTable
llvm-svn: 61007
2008-12-14 17:27:25 +00:00
Douglas Gregor 91f84216f7 Unifies the name-lookup mechanisms used in various parts of the AST
and separates lexical name lookup from qualified name lookup. In
particular:
  * Make DeclContext the central data structure for storing and
    looking up declarations within existing declarations, e.g., members
    of structs/unions/classes, enumerators in C++0x enums, members of
    C++ namespaces, and (later) members of Objective-C
    interfaces/implementations. DeclContext uses a lazily-constructed
    data structure optimized for fast lookup (array for small contexts,
    hash table for larger contexts). 

  * Implement C++ qualified name lookup in terms of lookup into
    DeclContext.

  * Implement C++ unqualified name lookup in terms of
    qualified+unqualified name lookup (since unqualified lookup is not
    purely lexical in C++!)

  * Limit the use of the chains of declarations stored in
    IdentifierInfo to those names declared lexically.

  * Eliminate CXXFieldDecl, collapsing its behavior into
    FieldDecl. (FieldDecl is now a ScopedDecl).

  * Make RecordDecl into a DeclContext and eliminates its
    Members/NumMembers fields (since one can just iterate through the
    DeclContext to get the fields).

llvm-svn: 60878
2008-12-11 16:49:14 +00:00
Chris Lattner 1cbaacc4a0 Migrate some stuff from NamedDecl::getName() to
NamedDecl::getNameAsString() to make it more explicit.

llvm-svn: 59937
2008-11-24 04:00:27 +00:00
Chris Lattner e4b95698df Rename Selector::getName() to Selector::getAsString(), and add
a new NamedDecl::getAsString() method.

Change uses of Selector::getName() to just pass in a Selector 
where possible (e.g. to diagnostics) instead of going through
an std::string.

This also adds new formatters for objcinstance and objcclass
as described in the dox.

llvm-svn: 59933
2008-11-24 03:33:13 +00:00
Douglas Gregor 163c58502a Extend DeclarationName to support C++ overloaded operators, e.g.,
operator+, directly, using the same mechanism as all other special
names.

Removed the "special" identifiers for the overloaded operators from
the identifier table and IdentifierInfo data structure. IdentifierInfo
is back to representing only real identifiers.

Added a new Action, ActOnOperatorFunctionIdExpr, that builds an
expression from an parsed operator-function-id (e.g., "operator
+"). ActOnIdentifierExpr used to do this job, but
operator-function-ids are no longer represented by IdentifierInfo's.

Extended Declarator to store overloaded operator names. 
Sema::GetNameForDeclarator now knows how to turn the operator
name into a DeclarationName for the overloaded operator. 

Except for (perhaps) consolidating the functionality of
ActOnIdentifier, ActOnOperatorFunctionIdExpr, and
ActOnConversionFunctionExpr into a common routine that builds an
appropriate DeclRefExpr by looking up a DeclarationName, all of the
work on normalizing declaration names should be complete with this
commit.

llvm-svn: 59526
2008-11-18 14:39:36 +00:00