Commit Graph

4834 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis dfc5dca1e5 Don't use operator overload '<' for SourceLocation, it has not semantic meaning.
llvm-svn: 73932
2009-06-23 00:42:15 +00:00
Ted Kremenek 8bae300ade MemRegionManager: Migrate logic for getAllocaRegion() over to using trait-based MemRegion creation.
llvm-svn: 73927
2009-06-23 00:15:41 +00:00
Fariborz Jahanian 477d242a2e patch to mark use of implicit copy constructors.
llvm-svn: 73922
2009-06-22 23:34:40 +00:00
Ted Kremenek 214cdfea84 Migrate factory methods for FieldRegion and ObjCIVarRegion creation to use the
new generalized region-construction code.

llvm-svn: 73921
2009-06-22 23:34:21 +00:00
Ted Kremenek e5e8b0b09b Refactor some of the logic in MemRegionManager for constructing regions using
member template functions and traits. The idea is to allow MemRegionManager to
construct subclasses of MemRegion that aren't declared in MemRegion.h (e.g.,
checker-specific regions).

llvm-svn: 73917
2009-06-22 23:13:13 +00:00
Chris Lattner 6589a2e1db add a warning group for unavailable decls that mirrors the one for
deprecated decls.

llvm-svn: 73914
2009-06-22 23:04:45 +00:00
Douglas Gregor 0b6a6242ed Rework the way we track which declarations are "used" during
compilation, and (hopefully) introduce RAII objects for changing the
"potentially evaluated" state at all of the necessary places within
Sema and Parser. Other changes:

  - Set the unevaluated/potentially-evaluated context appropriately
    during template instantiation.
  - We now recognize three different states while parsing or
    instantiating expressions: unevaluated, potentially evaluated, and
    potentially potentially evaluated (for C++'s typeid).
  - When we're in a potentially potentially-evaluated context, queue
    up MarkDeclarationReferenced calls in a stack. For C++ typeid
    expressions that are potentially evaluated, we will play back
    these MarkDeclarationReferenced calls when we exit the
    corresponding potentially potentially-evaluated context.
  - Non-type template arguments are now parsed as constant
    expressions, so they are not potentially-evaluated.

llvm-svn: 73899
2009-06-22 20:57:11 +00:00
Fariborz Jahanian 3a36343b88 Remove ImplicitMustBeDefined, use universal 'Used' flag
instead. Do the implicit default ctor checking in MarkDeclarationReferenced.

llvm-svn: 73888
2009-06-22 17:30:33 +00:00
Argyrios Kyrtzidis 49abd4d95b Addressing Doug's suggestions:
-Added comment for FunctionDecl::EndRangeLoc
-Removed a redundant check from FunctionDecl::setBody

llvm-svn: 73886
2009-06-22 17:13:31 +00:00
Fariborz Jahanian 246219bc9f Fixed text of a diagnostics.
llvm-svn: 73885
2009-06-22 16:33:37 +00:00
Fariborz Jahanian 99b57fb987 Renamed Protocol as TheProtocol so people can use clang header for
building obj-c++ clients. "Protocol" is a class name in Cocoa.h

llvm-svn: 73854
2009-06-21 18:26:03 +00:00
Fariborz Jahanian 1c9d5d956c Made improvements in c++'s object model patch on Doug's review.
llvm-svn: 73833
2009-06-20 20:23:38 +00:00
Argyrios Kyrtzidis 3a08ec1662 Add the license part to the new source files.
llvm-svn: 73825
2009-06-20 08:27:14 +00:00
Argyrios Kyrtzidis 88f663c04d Introduce SourceManager::getLocation() to get a source location out of a "file:line:column" triplet.
llvm-svn: 73823
2009-06-20 08:09:57 +00:00
Argyrios Kyrtzidis a3aeb5a8f1 Introduce Decl::getSourceRange() which, like Stmt::getSourceRange(), represents the range that the declaration covers.
Add initial support for NamespaceDecl, VarDecl, and FunctionDecl:
-NamespaceDecl range is from name to '}'
-VarDecl is from name to possible init expression
-FunctionDecl is from name to last parameter name or to end of its function body.

llvm-svn: 73821
2009-06-20 08:09:14 +00:00
Argyrios Kyrtzidis ef21d5d870 Add operator '<=' for comparing SourceLocations.
llvm-svn: 73820
2009-06-20 08:08:38 +00:00
Argyrios Kyrtzidis ce3797527e Introduce the ASTUnit class.
ASTUnit is a helper class to allow easy loading of an ASTContext from a PCH file. No users for now.

llvm-svn: 73819
2009-06-20 08:08:23 +00:00
Douglas Gregor fec52635f0 Parsing and AST support for using declarations, from John Thompson!
llvm-svn: 73812
2009-06-20 00:51:54 +00:00
Douglas Gregor c9c02ed8f4 Keep track of when declarations are "used" according to C and
C++. This logic is required to trigger implicit instantiation of
function templates and member functions of class templates, which will
be implemented separately.

This commit includes support for -Wunused-parameter, printing warnings
for named parameters that are not used within a function/Objective-C
method/block. Fixes <rdar://problem/6505209>.

llvm-svn: 73797
2009-06-19 23:52:42 +00:00
Fariborz Jahanian 3fd7310d70 Use QualType to represent block's implicit return type as
to not lose its 'const/volatile' qualifier.

llvm-svn: 73795
2009-06-19 23:37:08 +00:00
Fariborz Jahanian 423a81f259 Patch for implementation of C++'s object model. This is
work in progress.

llvm-svn: 73782
2009-06-19 19:55:27 +00:00
Ted Kremenek c55f0cdaa0 Remove more GetSVal/GetLValue methods in GRExprEngine/GRState, instead
preferring to use their replacements in GRState. This further unifies the code
paths for such logic and leads to some code reduction.

llvm-svn: 73771
2009-06-19 17:10:32 +00:00
Zhongxing Xu 54fb536b5c A further step of r73690: associate the cast-to type with the created symbol,
because the type of the symbol is used to create the default range. We need the
sign to be consistent.

llvm-svn: 73756
2009-06-19 06:00:32 +00:00
Argyrios Kyrtzidis 366985d5eb Make changes to PCHReader to allow reading a PCH file without having a pre-initialized Preprocessor.
-Introduce 'PCHReaderListener' which is an abstract interface for getting various information from the PCHReader.
-If PCHReader is constructed without a Preprocessor, it can still load the file and invoke the callbacks of PCHReaderListener.
-If PCHReader is constructed with an initialized Preprocessor, PCHValidator is used as a PCHReaderListener to validate the contents of the PCH file against the given Preprocessor.

llvm-svn: 73741
2009-06-19 00:03:23 +00:00
Ted Kremenek 095f1a9848 Move clients over from using GRStateManager::BindXXX and friends to
GRState->bindXXX and friends (and constify some arguments along the way).

llvm-svn: 73740
2009-06-18 23:58:37 +00:00
Ted Kremenek f9906843b7 libAnalysis:
- Remove the 'isFeasible' flag from all uses of 'Assume'.
- Remove the 'Assume' methods from GRStateManager.  Now the only way to
  create a new GRState with an assumption is to use the new 'assume' methods
  in GRState.

llvm-svn: 73731
2009-06-18 22:57:13 +00:00
Douglas Gregor 1e09bf83c0 Some cleanups suggested by Chris
llvm-svn: 73713
2009-06-18 18:45:36 +00:00
Douglas Gregor 78bd61f661 Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
llvm-svn: 73702
2009-06-18 16:11:24 +00:00
Zhongxing Xu cea6578078 When casting region, if we do not create an element region, record the cast-to
type. 

When retrieving the region value, if we are going to create a symbol value, use
the cast-to type if possible.

llvm-svn: 73690
2009-06-18 06:29:10 +00:00
Zhongxing Xu dd19e15fe2 More GRStateRef removal fix.
llvm-svn: 73674
2009-06-18 03:42:19 +00:00
Ted Kremenek 6a667ab710 Remove GRStateRef.
llvm-svn: 73670
2009-06-18 01:33:24 +00:00
Ted Kremenek d93c6e3fd6 Remove more dependencies on GRStateRef. As a consequence, we can now
pretty-print a GRState object anywhere it is referenced (instead of
needing a GRStateRef of a GRStateManager handy).

llvm-svn: 73669
2009-06-18 01:23:53 +00:00
Ted Kremenek 89a303caac Remove another dependency on GRStateRef.
llvm-svn: 73667
2009-06-18 00:49:02 +00:00
Argyrios Kyrtzidis 3df1978270 Implement correct name lookup inside an initializer of a C++ class static data member.
Fixes "test/CXX/basic/basic.lookup/basic.lookup.unqual/p13.cpp" test case.

llvm-svn: 73652
2009-06-17 22:50:06 +00:00
Argyrios Kyrtzidis c4b766bc65 Move CXXMethodDecl::OutOfLineDefinition into Decl::OutOfLine.
llvm-svn: 73651
2009-06-17 22:49:50 +00:00
Steve Naroff fb4330f255 First step toward fixing <rdar://problem/6613046> refactor clang objc type representation.
Add a type (ObjCObjectPointerType) and remove a type (ObjCQualifiedIdType).

This large/tedious patch is just a first step. Next step is to remove ObjCQualifiedInterfaceType. After that, I will remove the magic TypedefType for 'id' (installed by Sema). This work will enable various simplifications throughout clang (when dealing with ObjC types). 

No functionality change.

llvm-svn: 73649
2009-06-17 22:40:22 +00:00
Ted Kremenek b35e2caab5 Remove more uses of GRStateRef.
llvm-svn: 73648
2009-06-17 22:28:13 +00:00
Ted Kremenek d0d4cfc8e7 Class 'Environment' no longer should subclass llvm::FoldingSetNode.
Environment hasn't been uniqued in a FoldingSet for some time, so this
was just wasting a pointer in GRState.

llvm-svn: 73645
2009-06-17 22:06:03 +00:00
Ted Kremenek 609df30929 Start moving in the direction of removing GRStateRef. Now each
GRState object has a direct reference to its GRStateManager, making
the functionality of GRStateRef redunandant.  This will lead to some
nice API cleanup and code shrinking across libAnalysis.

llvm-svn: 73644
2009-06-17 22:02:04 +00:00
Douglas Gregor 758a869b14 Support dependent extended vector types and template instantiation
thereof. Patch by Anders Johnsen!

llvm-svn: 73641
2009-06-17 21:51:59 +00:00
Fariborz Jahanian ccd44a5072 Added missing @endcode.
llvm-svn: 73629
2009-06-17 20:24:52 +00:00
Douglas Gregor 6b6bba4a20 Diagnose the use of attributes on namespace aliases, from Anis Ahmad
llvm-svn: 73626
2009-06-17 19:49:00 +00:00
Anders Carlsson 58a9b0eafe Remove all non-const getters from TemplateArgumentList.
llvm-svn: 73589
2009-06-17 00:35:01 +00:00
Fariborz Jahanian 5b130a56fd Place -Wreadonly-setter-attrs under -Wmost option group.
llvm-svn: 73585
2009-06-17 00:06:21 +00:00
Daniel Dunbar 1b3ec3a000 Fake support for -print-multi-*
- I think we will eventually need to support this for realz, and some build
   processes seem to depend on these options.

llvm-svn: 73581
2009-06-16 23:25:22 +00:00
Ted Kremenek b538e7b64f Add utility method GRStateRef::makeWithStore().
llvm-svn: 73576
2009-06-16 22:55:21 +00:00
Ted Kremenek 4533a55696 RegionStoreManager:
- Add "sections" to RegionStoreManager.cpp to delineate functionality.
- Add new function "CreateFieldsOnlyRegionStoreManager" that uses the new
  RegionStoreFeatures class to use a reduced set of features from
  RegionStoreManager (in this case, only field-sensitivity). This isn't
  completely hooked up yet.

llvm-svn: 73572
2009-06-16 22:36:44 +00:00
Douglas Gregor 71544dba9d Don't warn about -Winvalid-pch or -Wno-invalid-pch. Since we don't
search for PCH files that correspond to header inclusions, this option
does not make sense. Fixes <rdar://problem/6970322>.

llvm-svn: 73563
2009-06-16 22:06:52 +00:00
Chris Lattner 392da9c56d simplify .td file
llvm-svn: 73542
2009-06-16 20:04:21 +00:00
Fariborz Jahanian 4be3f263c7 Add -Wundeclared-selector to -Wmost options group.
llvm-svn: 73524
2009-06-16 18:20:59 +00:00
Fariborz Jahanian 0571d9bbba Implements -Wundeclared-selector for ObjC.
llvm-svn: 73495
2009-06-16 16:25:00 +00:00
Chris Lattner 4ef49c1d6e my refactoring of builtins changed target-specific builtins to only be
registered when PCH wasn't being used.  We should always install (in BuiltinInfo)
information about target-specific builtins, but we shouldn't register any builtin
identifier infos.  This fixes the build of apps that use PCH and target specific
builtins together.

llvm-svn: 73492
2009-06-16 16:18:48 +00:00
Zhongxing Xu 838a0db0ba Use canonical type for building ElementRegion. Otherwise ElementRegions cannot
be unique.

llvm-svn: 73482
2009-06-16 09:55:50 +00:00
Anders Carlsson a42ab8f3d5 Handle temporaries in default arguments.
llvm-svn: 73462
2009-06-16 03:37:31 +00:00
Anders Carlsson 90036dc96a Keep track of whether a type parameter type is a parameter pack.
llvm-svn: 73452
2009-06-16 00:30:48 +00:00
Chris Lattner 49ffbb73ce accept and ignore -Wdiv-by-zero
llvm-svn: 73446
2009-06-15 23:45:43 +00:00
Anders Carlsson ebf5be8db9 Include <limits>
llvm-svn: 73403
2009-06-15 19:08:31 +00:00
Douglas Gregor f39bf33dc0 More XML output support, from Olaf Krzikalla!
llvm-svn: 73402
2009-06-15 19:02:54 +00:00
Anders Carlsson 475501b01c More parameter pack work.
llvm-svn: 73395
2009-06-15 17:56:45 +00:00
Anders Carlsson bc34391f04 Add a new 'Pack' argument kind to TemplateArgument. This is not yet used.
llvm-svn: 73391
2009-06-15 17:04:53 +00:00
Douglas Gregor 33834516f3 Update LLVM.
Implement support for C++ Substitution Failure Is Not An Error
(SFINAE), which says that errors that occur during template argument
deduction do *not* produce diagnostics and do not necessarily make a
program ill-formed. Instead, template argument deduction silently
fails. This is currently implemented for template argument deduction
during matching of class template partial specializations, although
the mechanism will also apply to template argument deduction for
function templates. The scheme is simple:

  - If we are in a template argument deduction context, any diagnostic
    that is considered a SFINAE error (or warning) will be
    suppressed. The error will be propagated up the call stack via the
    normal means.
  - By default, all warnings and errors are SFINAE errors. Add the
    NoSFINAE class to a diagnostic in the .td file to make it a hard
    error (e.g., for access-control violations).

Note that, to make this fully work, every place in Sema that emits an
error *and then immediately recovers* will need to check
Sema::isSFINAEContext() to determine whether it must immediately
return an error rather than recovering.

llvm-svn: 73332
2009-06-14 07:33:30 +00:00
Chris Lattner 15ba94987a Sink the BuiltinInfo object from ASTContext into the
preprocessor and initialize it early in clang-cc.  This
ensures that __has_builtin works in all modes, not just
when ASTContext is around.

llvm-svn: 73319
2009-06-14 01:54:56 +00:00
Chris Lattner 5abdec7978 move the various builtins stuff from libast to libbasic. This
fixes a layering violation in lib/Basic/Targets.cpp.

llvm-svn: 73318
2009-06-14 01:05:48 +00:00
Chris Lattner 3d4ead17c7 prune #includes, Builtins.h/cpp no longer depends on libast.
llvm-svn: 73317
2009-06-14 00:52:07 +00:00
Chris Lattner ecd79c6353 move GetBuiltinType from Builtin::Context to ASTContext.
llvm-svn: 73316
2009-06-14 00:45:47 +00:00
Chris Lattner 34a9566c8c improve localizability by not passing english phrases into
diagnostics in some cases.

llvm-svn: 73314
2009-06-14 00:07:48 +00:00
Chris Lattner a744527773 add a handy predicate.
llvm-svn: 73310
2009-06-13 23:31:51 +00:00
Chris Lattner b3c4fb5cac declare an 'operator delete' to match operator new, this avoids many many
warnings when building with VC++, patch by AlisdairM!

llvm-svn: 73305
2009-06-13 20:51:38 +00:00
Anders Carlsson 40c1d49615 Have CheckClassTemplatePartialSpecializationArgs take a TemplateArgumentListBuilder. No functionality change.
llvm-svn: 73297
2009-06-13 18:20:51 +00:00
Chris Lattner b6f77af532 implement and document a new __has_feature and __has_builtin magic
builtin preprocessor macro.  This appears to work with two caveats:
1) builtins are registered in -E mode, and 2) target-specific builtins
are unconditionally registered even if they aren't supported by the
target (e.g. SSE4 builtin when only SSE1 is enabled).

llvm-svn: 73289
2009-06-13 07:13:28 +00:00
Anders Carlsson 15201f19ba More work on type parameter packs.
llvm-svn: 73281
2009-06-13 02:08:00 +00:00
Douglas Gregor 91772d1d76 When some template parameters of a class template partial
specialization cannot be deduced, produce a warning noting that the
affected class template partial specialization will never be used.

llvm-svn: 73274
2009-06-13 00:26:55 +00:00
Anders Carlsson aa73b9135a Improvements to TemplateArgumentListBuilder to make it work better with parameter packs.
llvm-svn: 73272
2009-06-13 00:08:58 +00:00
Anders Carlsson 327865db53 A parameter pack must always come last in a class template.
llvm-svn: 73269
2009-06-12 23:20:15 +00:00
Anders Carlsson f986ba7528 Address more comments from Doug.
llvm-svn: 73267
2009-06-12 23:09:56 +00:00
Chris Lattner 815b70efcd add the location of the ')' in a do/while statement to DoStmt.
This fixes a source range problem reported by Olaf Krzikalla.

llvm-svn: 73266
2009-06-12 23:04:47 +00:00
Anders Carlsson d382435014 Parameter packs can't have default arguments.
llvm-svn: 73262
2009-06-12 22:30:13 +00:00
Anders Carlsson fb1d776ff0 Keep track of whether a type parameter is actually a type parameter pack.
llvm-svn: 73261
2009-06-12 22:23:22 +00:00
Douglas Gregor 30b0197169 Finish implementing checking of class template partial specializations
llvm-svn: 73260
2009-06-12 22:21:45 +00:00
Douglas Gregor 09a3023e65 Diagnose C++ [temp.class.spec]p9b3, where a class template partial
specialization's arguments are identical to the implicit template
arguments of the primary template. Typically, this is meant to be a
declaration/definition of the primary template, so we give that
advice.

llvm-svn: 73259
2009-06-12 22:08:06 +00:00
Douglas Gregor 8cfd2ba76d Diagnose the incorrect use of non-type template arguments for class
template partial specializations.

llvm-svn: 73254
2009-06-12 21:21:02 +00:00
Anders Carlsson 01e9e93485 Parse support for C++0x type parameter packs.
llvm-svn: 73247
2009-06-12 19:58:00 +00:00
Douglas Gregor d52220513f Verify that the template parameters of a class template partial
specialization do not have default arguments 
(C++ [temp.class.spec]p10). 

llvm-svn: 73245
2009-06-12 19:43:02 +00:00
Douglas Gregor 181aa4a250 Improve template argument deduction to keep track of why template
argument deduction failed. For example, given

  template<typename T> struct is_same<T, T> { ... };

template argument deduction will fail for is_same<int, float>, and now
reports enough information

Right now, we don't do anything with this extra information, but it
can be used for informative diagnostics that say, e.g., "template
argument deduction failed because T was deduced to 'int' in one
context and 'float' in another".

llvm-svn: 73237
2009-06-12 18:26:56 +00:00
Anders Carlsson 84613c4eba It's an error to use a function declared in a class definition as a default argument before the function has been declared.
llvm-svn: 73234
2009-06-12 16:51:40 +00:00
Douglas Gregor 637d9984f0 Template argument deduction for member pointers.
Also, introduced some of the framework for performing instantiation as
part of template argument deduction.

llvm-svn: 73175
2009-06-10 23:47:09 +00:00
Douglas Gregor 0bdc1f5eef Handle member pointer types with dependent class types (e.g., int
T::*) and implement template instantiation for member pointer types.

llvm-svn: 73151
2009-06-09 22:17:39 +00:00
Eli Friedman 53339e0fdb Add more parser support for Microsoft extensions.
llvm-svn: 73101
2009-06-08 23:27:34 +00:00
Daniel Dunbar db09702e2a PR4016: Forward -fno-show-source-location to clang.
llvm-svn: 73082
2009-06-08 21:13:54 +00:00
Eli Friedman 06de2b5525 Add real parsing for __declspec. It doesn't make much of a difference
at the moment because we ignore the result.

llvm-svn: 73056
2009-06-08 07:21:15 +00:00
Eli Friedman aa27a87ab3 Misc minor fixes for clang for the Windows target.
llvm-svn: 73050
2009-06-08 06:11:14 +00:00
Eli Friedman a6638ca3a3 Delete method which is now trivial.
llvm-svn: 73043
2009-06-08 05:08:54 +00:00
Chris Lattner 6143fb504c teach clang that -Wunused turns on all unused warnings, even though most
of these are not implemented yet.

llvm-svn: 73042
2009-06-08 04:26:30 +00:00
Anders Carlsson 0880e9f58d Instantiation support for more Obj-C expressions, string literals, @selector and @protocol expressions.
llvm-svn: 73036
2009-06-07 19:51:47 +00:00
Anders Carlsson 315d2294f8 Template instantiation support for Obj-C @encode expressions.
llvm-svn: 73034
2009-06-07 18:45:35 +00:00
Eli Friedman e9ff191459 Remove a few more vector builtins.
llvm-svn: 73022
2009-06-07 09:32:56 +00:00
Eli Friedman 5a996fc0fc Now that LLVM CodeGen can handle the generic variations a bit better,
get rid of a few more clang vector builtins.

llvm-svn: 73015
2009-06-07 07:12:56 +00:00
Eli Friedman 6813eb125f Get rid of a bunch of dead builtins.
llvm-svn: 72996
2009-06-06 08:31:46 +00:00
Anders Carlsson 8544647e9c Make ParmVarDecl::getDefaultArg() more robust, it now asserts that the argument is not unparsed. Add a new hasDefaultArg() and use it in places where getDefaultArg() was called when the argument was unparsed.
llvm-svn: 72984
2009-06-06 04:14:07 +00:00
Devang Patel 9e24386c65 Set function Attribute::NoImplicitFloat appropriately.
llvm-svn: 72961
2009-06-05 22:05:48 +00:00
Fariborz Jahanian 6845383426 Use of DeclContext for objc's ivars. No functionality
change. More to follow.

llvm-svn: 72951
2009-06-05 18:16:35 +00:00
Anders Carlsson b3d05d6d11 Improvements to CXXExprWithTemporaries in preparation for fixing a bug with default arguments that have temporaries.
llvm-svn: 72944
2009-06-05 15:38:08 +00:00
Eli Friedman 2468f8625a PR3443: Add stpcpy builtin (plus a few other related builtins). Yes,
we're still missing a mechanism to disable these in strict mode, but 
that's not a new issue.

llvm-svn: 72936
2009-06-05 08:20:10 +00:00
Eli Friedman 327f0b5593 Add driver support for -fsigned-char/-funsigned-char.
llvm-svn: 72930
2009-06-05 07:21:14 +00:00
Eli Friedman 9ffd4a9b96 Move CharIsSigned from TargetInfo to LangOptions.
llvm-svn: 72928
2009-06-05 07:05:05 +00:00
Eli Friedman d7bcad67d4 Add a couple of FreeBSD-specific command-line options.
llvm-svn: 72927
2009-06-05 06:29:09 +00:00
Eli Friedman 302c4e1683 Address review comments for #pragma weak.
llvm-svn: 72926
2009-06-05 06:28:29 +00:00
Anders Carlsson 184cb4123e Make TemplateArgumentListBuilder take an ASTContext (because we're probably going to need it later). Move push_back to the .cpp file. If the passed in template argument is a type, assert that it's canonical.
llvm-svn: 72918
2009-06-05 05:31:27 +00:00
Anders Carlsson c8e7113a9f Make the TemplateArgumentList take a TemplateArgumentListBuilder.
llvm-svn: 72917
2009-06-05 04:47:51 +00:00
Anders Carlsson 1b28c3efe2 Change the specialization decls to take a TemplateArgumentListBuilder.
llvm-svn: 72916
2009-06-05 04:06:48 +00:00
Anders Carlsson 8aa89d4049 Add a helper class for building template argument lists.
llvm-svn: 72915
2009-06-05 03:43:12 +00:00
Eli Friedman 5ed5198a5a Start of a Sema implementation for #pragma weak. This isn't really the
right approach, but I'm still not sure what the best way to go about this is.

llvm-svn: 72912
2009-06-05 02:44:36 +00:00
Douglas Gregor b7ae10f764 Several improvements to template argument deduction:
- Once we have deduced template arguments for a class template partial
    specialization, we use exactly those template arguments for instantiating
    the definition of the class template partial specialization.
  - Added template argument deduction for non-type template parameters.
  - Added template argument deduction for dependently-sized array types.

With these changes, we can now implement, e.g., the remove_reference
type trait. Also, Daniel's Ackermann template metaprogram now compiles
properly.

llvm-svn: 72909
2009-06-05 00:53:49 +00:00
Eli Friedman f5867dd51a Add parser support for #pragma weak.
llvm-svn: 72907
2009-06-05 00:49:58 +00:00
Devang Patel 6e467b1a46 Set function attribute llvm::Attribute::NoRedZone appropriately.
llvm-svn: 72902
2009-06-04 23:32:02 +00:00
Eli Friedman 8001b35d5d Clean up builtin lists, add a few new builtins. (I re-sorted the
string.h builtins to be in the same order as the list in the C99 
standard.)

llvm-svn: 72882
2009-06-04 19:35:30 +00:00
Torok Edwin a1581e1a7a forward -fno-color-diagnostics to clang-cc.
llvm-svn: 72856
2009-06-04 07:27:53 +00:00
Torok Edwin c91b6e0ff8 Add ANSI color support for clang.
llvm-svn: 72855
2009-06-04 07:18:23 +00:00
Fariborz Jahanian 7c80959a97 Cleanup/Refactoring of ivar collection. No change in functionality.
llvm-svn: 72827
2009-06-04 01:19:09 +00:00
Douglas Gregor 55ca8f6443 When performing template argument deduction, ensure that multiple
deductions of the same template parameter are equivalent. This allows
us to implement the is_same type trait (!).

Also, move template argument deduction into its own file and update a
few build systems with this change (grrrr).

llvm-svn: 72819
2009-06-04 00:03:07 +00:00
Eli Friedman 7c54f66058 PR4308: Fix support for -m32/-m64 on Linux.
I'll look into cleaning this up a bit as a followup.

llvm-svn: 72794
2009-06-03 18:59:56 +00:00
Daniel Dunbar 877b30f83c Driver: Support -mllvm; this just forwards options to clang-cc.
llvm-svn: 72780
2009-06-03 16:16:27 +00:00
Eli Friedman aef810900a Minor cleanup for implicit int warnings.
llvm-svn: 72770
2009-06-03 12:22:01 +00:00
Eli Friedman 4e627efc55 Fix up a bunch of warnings to use ExtWarn so they interact with
-pedantic-errors correctly.

llvm-svn: 72769
2009-06-03 12:07:19 +00:00
Eli Friedman c563b497ab Add support for -Wempty-body.
llvm-svn: 72766
2009-06-03 11:10:10 +00:00
Eli Friedman 8246b6f889 PR4290: Handle vfprintf in a way that doesn't give any diagnostics for
valid declarations and doesn't give an error for autoconf-style invalid 
redeclarations.  This isn't quite ideal, but I don't see any other way 
easy way to handle it.  (The only thing I can think of that's reasonably 
general is adding a new builtin type FILETy which is only compatible 
with a type equivalent to FILE, and that seems like overkill.)

llvm-svn: 72760
2009-06-03 09:54:50 +00:00
Daniel Dunbar 4b665ebb01 Add clang-cc support for -disable-llvm-optzns.
- Avoids running any LLVM optimizations, even at -O2, etc., while still keeping
   any language changes these optimizations imply.

llvm-svn: 72742
2009-06-02 22:07:45 +00:00
Eli Friedman 47b8a8d522 Missing file for __builtin_unwind_init support.
llvm-svn: 72728
2009-06-02 09:39:16 +00:00
Eli Friedman cb8302ee3e Add builtin declarations for the variants of sin and cos.
llvm-svn: 72718
2009-06-02 07:06:02 +00:00
Eli Friedman 28d85c0803 Add --shared option.
llvm-svn: 72716
2009-06-02 05:46:32 +00:00
Fariborz Jahanian c6d9800564 A corner case of objc2 gc's write-barrier generation
for the Next runtime.

llvm-svn: 72703
2009-06-01 21:29:32 +00:00
Anders Carlsson a8decaa7c2 Fix a bug in hasEmptyExceptionSpec. (Thanks Sebastian for noticing).
llvm-svn: 72691
2009-06-01 15:02:12 +00:00
Eli Friedman d8cec57b9d PR4283: Don't truncate multibyte character constants in the
preprocessor.

llvm-svn: 72686
2009-06-01 05:25:02 +00:00
Anders Carlsson cba81fc4de Improve irgen of 'new' further.
llvm-svn: 72677
2009-05-31 21:53:59 +00:00
Chris Lattner 6e127a6d86 Downgrade an error about "return in a no-return function" from being
an error to being a warning that defaults to error.  If you want this to
be a warning, you have to explicitly pass -Winvalid-noreturn to clang to
map it back to a warning.

llvm-svn: 72669
2009-05-31 19:32:13 +00:00
Sebastian Redl fb3f1794e1 Disallow exception specs on typedefs.
llvm-svn: 72664
2009-05-31 11:47:27 +00:00
Douglas Gregor 2373c599b5 Initial infrastructure for class template partial specialization. Here
we have the basics of declaring and storing class template partial
specializations, matching class template partial specializations at
instantiation time via (limited) template argument deduction, and
using the class template partial specialization's pattern for
instantiation. 

This patch is enough to make a simple is_pointer type trait work, but
not much else.

llvm-svn: 72662
2009-05-31 09:31:02 +00:00
Anders Carlsson 89391a9272 Add more getters to the new AST nodes.
llvm-svn: 72651
2009-05-31 00:08:52 +00:00
Anders Carlsson 73b836bf3d Clean up the newly added C++ AST nodes.
llvm-svn: 72643
2009-05-30 22:38:53 +00:00
Anders Carlsson 5de832ecfa ActOnReturnStmt should also take a FullExprArg.
llvm-svn: 72641
2009-05-30 21:42:34 +00:00
Anders Carlsson 5e9444f541 AddInitializerToDecl needs to take a full expression.
llvm-svn: 72640
2009-05-30 21:37:25 +00:00
Anders Carlsson 4f44fd5c6f Get rid of CXXTempVarDecl.
llvm-svn: 72637
2009-05-30 21:10:34 +00:00
Anders Carlsson a29ded9ba8 Stop using CXXTempVarDecl and use CXXTemporary instead.
llvm-svn: 72634
2009-05-30 21:05:25 +00:00
Anders Carlsson 4b2434da54 Remove VarDecl from CXXConstructExpr.
llvm-svn: 72633
2009-05-30 20:56:46 +00:00
Anders Carlsson ffda606612 Small fixes to CXXTemporary and CXXBindTemporaryExpr.
llvm-svn: 72628
2009-05-30 20:34:37 +00:00
Anders Carlsson 993a4b3080 Add a CXXBindTemporaryExpr.
llvm-svn: 72627
2009-05-30 20:03:25 +00:00
Anders Carlsson f337d8c515 Add a CXXTemporary class. Not used yet.
llvm-svn: 72626
2009-05-30 19:54:15 +00:00
Douglas Gregor 182319375a Pretty printing and improved representation for namespace alias declarations
llvm-svn: 72616
2009-05-30 06:48:27 +00:00
Douglas Gregor 3bc6e4c72a Printing for using directives, e.g.,
using namespace std::debug;

Extended UsingDirectiveDecl to store the nested-name-specifier that
precedes the nominated namespace.

llvm-svn: 72614
2009-05-30 06:31:56 +00:00
Eli Friedman ef334fdfa2 Add a Stmt::printPretty overload which takes an ASTContext; start
transitioning callers over to pass one in.

llvm-svn: 72609
2009-05-30 05:03:24 +00:00
Eli Friedman 796358498f Expose an API to print a group of decls (like "int a,b;").
Make StmtPrinter use DeclPrinter to print all declarations.  Merge 
declarations in the limited case of an unnamed TagDecl followed by one 
or more declarations using that TagDecl directly.  Change
SuppressTypeSpecifiers to the more general SuppressSpecifiers, and 
use it to suppress stuff like "typedef" and "extern".  Replace 
OwnedTag with SuppressTag, since it's more convenient to print 
declarations from DeclPrinter at the moment.  
improvements to declaration printing.  Fix pretty-printing for K&R 
function definitions and __builtin_va_arg.

We're now to the point where the pretty-printing output for non-trivial 
programs can actually be piped back into clang.

llvm-svn: 72608
2009-05-30 04:20:30 +00:00
Eli Friedman d5ef49ff54 Add support for PrintingPolicy::SuppressTypeSpecifiers to type printing.
(I have a work-in-progress patch which uses this.)

llvm-svn: 72598
2009-05-30 00:10:16 +00:00
Douglas Gregor 278f52ec29 Refactor and clean up the AST printer, so that it uses a DeclVisitor,
walks through DeclContexts properly, and prints more of the
information available in the AST. The functionality is still available
via -ast-print, -ast-dump, etc., and also via the new member functions
Decl::dump() and Decl::print().

llvm-svn: 72597
2009-05-30 00:08:05 +00:00
Anders Carlsson 0a63741a3f Add code for emitting C++ destructors. Not used yet.
llvm-svn: 72591
2009-05-29 21:03:38 +00:00
Douglas Gregor 7de5966d76 Create a new PrintingPolicy class, which we pass down through the AST
printing logic to help customize the output. For now, we use this
rather than a special flag to suppress the "struct" when printing
"struct X" and to print the Boolean type as "bool" in C++ but "_Bool"
in C.

llvm-svn: 72590
2009-05-29 20:38:28 +00:00
Sebastian Redl d643456d45 Reject incomplete types in exception specs.
llvm-svn: 72580
2009-05-29 18:02:33 +00:00
Sebastian Redl 10b9de45c3 Disallow exception specifications on multi-level indirections.
llvm-svn: 72571
2009-05-29 15:01:05 +00:00
Eli Friedman 55b9ecbc7a If a declarator group declares a type, make sure to add that declaration
to the DeclGroup.

llvm-svn: 72559
2009-05-29 01:49:24 +00:00
Douglas Gregor d6ab8744dc When we parse a tag specifier, keep track of whether that tag
specifier resulted in the creation of a new TagDecl node, which
happens either when the tag specifier was a definition or when the tag
specifier was the first declaration of that tag type. This information
has several uses, the first of which is implemented in this commit:

  1) In C++, one is not allowed to define tag types within a type
  specifier (e.g., static_cast<struct S { int x; } *>(0) is
  ill-formed) or within the result or parameter types of a
  function. We now diagnose this.

  2) We can extend DeclGroups to contain information about any tags
  that are declared/defined within the declaration specifiers of a
  variable, e.g.,

    struct Point { int x, y, z; } p;

  This will help improve AST printing and template instantiation,
  among other things.

  3) For C99, we can keep track of whether a tag type is defined
  within the type of a parameter, to properly cope with cases like,
  e.g.,

    int bar(struct T2 { int x; } y) {
      struct T2 z;
    }

  We can also do similar things wherever there is a type specifier,
  e.g., to keep track of where the definition of S occurs in this
  legal C99 code:

    (struct S { int x, y; } *)0

  

llvm-svn: 72555
2009-05-28 23:31:59 +00:00
Douglas Gregor 9e927abc41 Introduced DeclContext::isDependentContext, which determines whether a
given DeclContext is dependent on type parameters. Use this to
properly determine whether a TagDecl is dependent; previously, we were
missing the case where the TagDecl is a local class of a member
function of a class template (phew!).

Also, make sure that, when we instantiate declarations within a member
function of a class template (or a function template, eventually),
that we add those declarations to the "instantiated locals" map so
that they can be found when instantiating declaration references.

Unfortunately, I was not able to write a useful test for this change,
although the assert() that fires when uncommenting the FIXME'd line in
test/SemaTemplate/instantiate-declref.cpp tells the "experienced user"
that we're now doing the right thing.

llvm-svn: 72526
2009-05-28 16:34:51 +00:00
Douglas Gregor e44a2adf41 Reimplement much of the way that we track nested classes in the
parser. Rather than placing all of the delayed member function
declarations and inline definitions into a single bucket corresponding
to the top-level class, we instead mirror the nesting structure of the
nested classes and place the delayed member functions into their
appropriate place. Then, when we actually parse the delayed member
function declarations, set up the scope stack the same way as it was
when we originally saw the declaration, so that we can find, e.g.,
template parameters that are in scope.

llvm-svn: 72502
2009-05-27 23:11:45 +00:00
Eli Friedman 259109f9df restrict is not a keyword in gnu89 mode. Change TokenKinds.def to
reflect that.

llvm-svn: 72500
2009-05-27 22:48:34 +00:00
Sebastian Redl 5068f77ac7 Reintroduce the home for exception specs, and make Sema fill it. However, keep the spec out of the canonical type this time. Net effect is currently nothing, because the spec isn't checked anywhere.
llvm-svn: 72498
2009-05-27 22:11:52 +00:00
Sebastian Redl a81b0b7ef5 Add a big test case for I-C-Es in C++, and a fix to make it work. The fix might not be the right way to do it.
llvm-svn: 72490
2009-05-27 19:34:06 +00:00
Douglas Gregor 7a74938fca Enumeration declarations that were instantiated from an enumeration
within a template now have a link back to the enumeration from which
they were instantiated. This means that we can now find the
instantiation of an anonymous enumeration.

llvm-svn: 72482
2009-05-27 17:20:35 +00:00
Fariborz Jahanian a4872a411c Initialize ObjCSenderDispatch in LangOptions.
Patch by Benjamin Kramer.

llvm-svn: 72476
2009-05-27 16:27:50 +00:00
Steve Naroff 4fc95aa0d4 Convert ObjC qualified type clients over to using iterators.
This allows me to remove some API that I don't want to carry over to ObjCObjectPointerType.

No functionality change.

llvm-svn: 72475
2009-05-27 16:21:00 +00:00
Douglas Gregor 31cf12c0a6 When evaluating a VarDecl as a constant or determining whether it is
an integral constant expression, maintain a cache of the value and the
is-an-ICE flag within the VarDecl itself. This eliminates
exponential-time behavior of the Fibonacci template metaprogram.

llvm-svn: 72428
2009-05-26 18:54:04 +00:00
Eli Friedman 5cd659fd32 Fix for PR4140: Add the start of a Linux toolchain (basically, just
barely enough to get the given usage of -print-file-name working).

llvm-svn: 72412
2009-05-26 07:52:18 +00:00
Anders Carlsson 00a2759ca9 Add a new CallExpr::getCallReturnType and use it in Expr::isLvalueInternal. No intended functionality change.
llvm-svn: 72410
2009-05-26 04:57:27 +00:00
Anders Carlsson b7e69b06b5 Remove a bunch of unused constructors
llvm-svn: 72407
2009-05-26 01:04:47 +00:00
Chris Lattner c7516835c3 reword a warning for clarity
llvm-svn: 72391
2009-05-25 18:18:56 +00:00
Chris Lattner 31cadd77ef default -Wnonnull to on.
llvm-svn: 72390
2009-05-25 18:13:00 +00:00
Chris Lattner fe5b4250a8 move some format group options around in the file. Move NonNull group into
DiagnosticGroups.td, and add it as part of -Wformat (which gets it into -Wall).

llvm-svn: 72389
2009-05-25 18:10:41 +00:00
Ted Kremenek 20e2630877 Use 'Exprs.data()' instead of 'Exprs.empty() ? NULL : ...'
llvm-svn: 72304
2009-05-23 00:22:11 +00:00
Douglas Gregor 5ce0f0eccf Fix the parent classes in TypeNodes.def, from Olaf Krzikalla
llvm-svn: 72293
2009-05-22 22:48:45 +00:00
Ted Kremenek ed28b6d028 Modify begin()/end() for AsmStmt iterators to handle the case when Exprs.empty()
is true. Because of recent changes to llvm::SmallVector, using these iterators
when Exprs was empty would cause an assertion failure.

This fixes: PR 4245.

llvm-svn: 72286
2009-05-22 22:03:22 +00:00
Fariborz Jahanian 88fead8c48 Cannot type cast @selector expressions.
llvm-svn: 72284
2009-05-22 21:42:52 +00:00
Douglas Gregor a8db954f24 Representation of and template instantiation for member
expressions. This change introduces another AST node,
CXXUnresolvedMemberExpr, that captures member references (x->m, x.m)
when the base of the expression (the "x") is type-dependent, and we
therefore cannot resolve the member reference yet.

Note that our parsing of member references for C++ is still quite
poor, e.g., we don't handle x->Base::m or x->operator int.

llvm-svn: 72281
2009-05-22 21:13:27 +00:00
Fariborz Jahanian a4404f21d1 This patch adds support for sender-aware dispatch in Objective-C for the GNU runtime, when
compiled with -fobjc-sender-dependent-dispatch.  This is used in AOP, COP, implementing object 
planes, and a few other things.
Patch by David Chisnall.

llvm-svn: 72275
2009-05-22 20:17:16 +00:00
Daniel Dunbar adeeb052ad Don't warn about -funit-at-a-time, and reject -fno-unit-at-a-time.
- We could just warn about -fno-unit-at-a-time, but in practice people using it
   probably aren't going to get what they want out of clang.

Also, use "clang" specified error for unsupported things instead of driver
unsupported error.

llvm-svn: 72272
2009-05-22 19:02:20 +00:00
Fariborz Jahanian db3a4c1388 (Next runtime only) check to see if class implements forwardInvocation method
and objects of this class are derived from 'NSProxy'.
Under such conditions, which means that every method possible is 
implemented in the class, we should not issue "Method definition not found" 
warnings.

llvm-svn: 72267
2009-05-22 17:12:32 +00:00
Argyrios Kyrtzidis 12179bc014 Handle correctly a very ugly part of the C++ syntax. We cannot disambiguate between a parenthesized type-id and
a paren expression without considering the context past the parentheses.

Behold:
  (T())x;  - type-id
  (T())*x; - type-id
  (T())/x; - expression
  (T());   - expression

llvm-svn: 72260
2009-05-22 10:24:42 +00:00
Argyrios Kyrtzidis 5da1f08587 Factor the compound literal parsing out from ParseParenExpression and into a new ParseCompoundLiteralExpression.
No functionality change.

llvm-svn: 72259
2009-05-22 10:24:05 +00:00
Argyrios Kyrtzidis 9a9c0f4eff Modification to ParseParenExpression.
Now it parses the cast expression unless 'stopIfCastExpr' is true.

llvm-svn: 72258
2009-05-22 10:23:40 +00:00
Argyrios Kyrtzidis 387a334656 Remove ParseSimpleParenExpression.
Embed its functionality into it's only user, ParseCXXCasts.
CXXCasts now get the "actual" expression directly, they no longer always receive a ParenExpr. This is better since the
parentheses are always part of the C++ casts syntax.

llvm-svn: 72257
2009-05-22 10:23:16 +00:00
Argyrios Kyrtzidis 7bd98440b3 Refactor the common code of 'ParseTypeofSpecifier' and 'ParseSizeofAlignofExpression' into a new
'ParseExprAfterTypeofSizeofAlignof' method.

llvm-svn: 72256
2009-05-22 10:22:50 +00:00
Daniel Dunbar 51c7f97bea (llvm up) Use llvm::Triple for storing target triples.
- This commit has some messy stuff in it to extend string lifetimes, but that
   will go away once we switch to using the enum'd Triple interfaces.

llvm-svn: 72243
2009-05-22 02:53:45 +00:00
Daniel Dunbar 58f345ceb1 Add --analyzer-no-default-checks and --analyzer-output options.
llvm-svn: 72238
2009-05-22 00:38:15 +00:00
Douglas Gregor ca1aeecd37 Template instantiation for C99 designated initializers, because we
can. Also, delay semantic analysis of initialization for
value-dependent as well as type-dependent expressions, since we can't
always properly type-check a value-dependent expression.

llvm-svn: 72233
2009-05-21 23:17:49 +00:00
Douglas Gregor 7f5601e55f AST XML dump, from Olaf Krzikalla!
llvm-svn: 72224
2009-05-21 20:55:50 +00:00
Fariborz Jahanian cd1a88da02 Check on null arguments in the presense of nonnull attribute.
llvm-svn: 72219
2009-05-21 18:48:51 +00:00
Douglas Gregor 728d41bbb9 Template instantiation for C++ throw expressions
llvm-svn: 72217
2009-05-21 17:37:52 +00:00
Douglas Gregor 269f0b1b69 Merge the ASTVector and ASTOwningVector templates, since they offered
redundant functionality. The result (ASTOwningVector) lives in
clang/Parse/Ownership.h and is used by both the parser and semantic
analysis. No intended functionality change.

llvm-svn: 72214
2009-05-21 16:25:11 +00:00
Jay Foad 7d0479f2c2 Use v.data() instead of &v[0] when SmallVector v might be empty.
llvm-svn: 72210
2009-05-21 09:52:38 +00:00
Douglas Gregor 1301fdd6c4 Introduce a new kind of RAII class, ASTOwningVector, which is an
llvm::SmallVector that owns all of the AST nodes inside of it. This
RAII class is used to ensure proper destruction of AST nodes when
template instantiation fails.

llvm-svn: 72186
2009-05-20 22:33:37 +00:00
Douglas Gregor e70f108158 Template instantiation for the various kinds of AST nodes that occur
due to C++ type construction of the form T(a1, a2, ..., aN).

llvm-svn: 72183
2009-05-20 21:38:11 +00:00
Douglas Gregor ce934146d0 Introduce a new expression type, CXXUnresolvedConstructExpr, to
describe the construction of a value of a given type using function
syntax, e.g.,
  
  T(a1, a2, ..., aN)

when the type or any of its arguments are type-dependent. In this
case, we don't know what kind of type-construction this will be: it
might construct a temporary of type 'T' (which might be a class or
non-class type) or might perform a conversion to type 'T'. Also,
implement printing of and template instantiation for this new
expression type. Due to the change in Sema::ActOnCXXTypeConstructExpr,
our existing tests cover template instantiation of this new expression
node.

llvm-svn: 72176
2009-05-20 18:46:25 +00:00
Fariborz Jahanian f1c25029b4 implementation of format_arg for ObjC methods/functions.
Still more to do.

llvm-svn: 72173
2009-05-20 17:41:43 +00:00
Zhongxing Xu a7907608fb * API change: we need to pass GRState to GRExprEngine::EvalBinOp() because
RegionStore needs to know the type of alloca region. 
* RegionStoreManager::EvalBinOp() now converts the alloca region to its first
  element region, as what is done to symbolic region.

llvm-svn: 72164
2009-05-20 09:00:16 +00:00