Daniel Dunbar [Wed, 18 Feb 2009 00:32:53 +0000 (00:32 +0000)]
Convert isIntegerConstantExpr to use ASTContext::MakeIntValue.
- This idiom ensures that the result will have the right width and
type.
- Tested on most of x86_64/llvm-test to satisfy my paranoia.
- This fixes at least the following bugs:
o UnaryTypeTraitExpr wasn't setting the width correctly.
o Arithmetic on _Bool wasn't setting the width correctly.
Daniel Dunbar [Wed, 18 Feb 2009 00:29:14 +0000 (00:29 +0000)]
Add ASTContext::MakeIntValue
- Makes an APSInt given a uint64_t and a type, with the appropriate
width and signedness to match the type. Yay for functional over
imperative.
Chris Lattner [Wed, 18 Feb 2009 00:25:15 +0000 (00:25 +0000)]
stop searching GCC install directories for standard C headers (but
keep searching for C++ headers when in C++ mode). In theory clang
should be able to find all of its own headers now. If not, the
CPATH or C_INCLUDE_PATH environment variables can be specified to
add a include path.
Douglas Gregor [Tue, 17 Feb 2009 23:15:12 +0000 (23:15 +0000)]
Implement basic parsing and semantic analysis for explicit
specialization of class templates, e.g.,
template<typename T> class X;
template<> class X<int> { /* blah */ };
Each specialization is a different *Decl node (naturally), and can
have different members. We keep track of forward declarations and
definitions as for other class/struct/union types.
This is only the basic framework: we still have to deal with checking
the template headers properly, improving recovery when there are
failures, handling nested name specifiers, etc.
Daniel Dunbar [Tue, 17 Feb 2009 22:16:19 +0000 (22:16 +0000)]
Eek! getDeclAlign sometimes returned alignment in bits.
- Renamed to getDeclAlignInBytes since most other query functions
work in bits.
- Fun to track down as isIntegerConstantExpr was getting it right,
but Evaluate() was getting it wrong. Maybe we should assert they
compute the same thing when they succeed?
Ted Kremenek [Tue, 17 Feb 2009 19:28:04 +0000 (19:28 +0000)]
Revised RangeConstraintManager based on several discussions with Ben Laurie and
Zhongxing Xu. The resultant code is less than 1/2 the size of the original.
Key highlights:
- All CouldBeXXX methods have been removed. Checking for feasibility is now just
done in the AddXXX methods.
- RangeSets now represent "all possible values" explicitly as the range set {
[min, max] } instead of the empty set. The empty set now represents "no
feasible values". This change consolidated much of the core algorithm to only
have one code path instead of alternate paths that considered the empty set to
represent "all possible falues."
Daniel Dunbar [Tue, 17 Feb 2009 18:43:32 +0000 (18:43 +0000)]
Change EmitConstantExpr to allow failure.
IRgen no longer relies on isConstantInitializer, instead we just try
to emit the constant. If that fails then in C we emit an error
unsupported (this occurs when Sema accepted something that it doesn't
know how to fold, and IRgen doesn't know how to emit) and in C++ we
emit a guarded initializer.
This ends up handling a few more cases, because IRgen was actually
able to emit some of the constants Sema accepts but can't Evaluate().
For example, PR3398.
Chris Lattner [Tue, 17 Feb 2009 08:44:50 +0000 (08:44 +0000)]
As an experimental hack, emit "instantiated from" information in
diagnostics. I'm not sure I want to keep this, but hey, it's easy
and could be useful or something, even if guarded by a
-fshow-me-tons-of-details option. A silly example is:
#define A B
#define C A
#define D C
int y = D;
We now emit:
t.c:11:9: error: use of undeclared identifier 'B'
int y = D;
^
t.c:9:11: note: instantiated from:
#define D C
^
t.c:8:11: note: instantiated from:
#define C A
^
t.c:7:11: note: instantiated from:
#define A B
^
A more useful example is from tgmath:
t.c:4:9: error: no matching function for call to '__tg_acos'
return acos(x);
^~~~~~~
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:51:17: note: instantiated from:
#define acos(x) __tg_acos(x)
^
... candidate set follows ...
This does not yet print ranges in instantiation info, (e.g. highlighting the
range "__tg_acos(x)" in the last example), but that could be added if we
decide this is a good idea :).
Chris Lattner [Tue, 17 Feb 2009 06:49:55 +0000 (06:49 +0000)]
fix notes so that they are always filtered with the same logic
as the last non-note diagnostic that preceeded them. This ensures
that diagnostics in main files which have notes with locations in
system headers get all the bits and pieces emitted or not in a
unit. This fixes PR3215.
Ted Kremenek [Tue, 17 Feb 2009 04:27:41 +0000 (04:27 +0000)]
Static Analyzer driver/options (partial) cleanup:
- Move all analyzer options logic to AnalysisConsumer.cpp.
- Unified specification of stores/constraints/output to be:
-analyzer-output=...
-analyzer-store=...
-analyzer-constraints=...
instead of -analyzer-range-constraints, -analyzer-store-basic, etc.
- Updated drivers (ccc-analyzer, scan-builds, new ccc) to obey this new
interface
- Updated test cases to conform to new driver options
Douglas Gregor [Tue, 17 Feb 2009 03:23:10 +0000 (03:23 +0000)]
Static variables and functions won't collide with standard library
functions, so if we're declaring a static we should implicitly declare
a library function by the same name (e.g., malloc, strdup). Fixes PR3592.
Chris Lattner [Tue, 17 Feb 2009 02:41:36 +0000 (02:41 +0000)]
explicitly cast integers to double. This a) silences any
possible future "data loss" warnings, and b) makes it intensely
obvious to the user what the impl of these functions do in a
ambiguity error.
Chris Lattner [Tue, 17 Feb 2009 02:30:54 +0000 (02:30 +0000)]
hand macro expand this to make "candidate" set printing more useful. However,
Now no candidates are printed because the 'notes' are in a system header. :(
Chris Lattner [Tue, 17 Feb 2009 02:14:31 +0000 (02:14 +0000)]
start converting over to attr(overloadable). Unfortunately, this
produces really horrible diagnostics when overload ambiguities
happen:
t.c:10:10: error: call to '__tg_acos' is ambiguous; candidates are:
return acos(x);
^~~~
In file included from t.c:1:
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
/Users/sabre/llvm/Debug/Headers/tgmath-sofar.h:49:1: note: candidate function
__TG_RC_1(x, acos, cacos)
^
A possible fix is to just not use macros for this, which I'll probably go for,
but it would be nice to emit the type at the call, so we know what we asked for!
Douglas Gregor [Tue, 17 Feb 2009 01:05:43 +0000 (01:05 +0000)]
Added ClassTemplateSpecializationDecl, which is a subclass of
CXXRecordDecl that is used to represent class template
specializations. These are canonical declarations that can refer to
either an actual class template specialization in the code, e.g.,
template<> class vector<bool> { };
or to a template instantiation. However, neither of these features is
actually implemented yet, so really we're just using (and uniqing) the
declarations to make sure that, e.g., A<int> is a different type from
A<float>. Note that we carefully distinguish between what the user
wrote in the source code (e.g., "A<FLOAT>") and the semantic entity it
represents (e.g., "A<float, int>"); the former is in the sugared Type,
the latter is an actual Decl.
Daniel Dunbar [Mon, 16 Feb 2009 22:43:43 +0000 (22:43 +0000)]
Support IRgen of sqrt -> llvm.sqrt, pow -> llvm.pow.
- Define pow[lf]?, sqrt[lf]? as builtins.
- Add -fmath-errno option which binds to LangOptions.MathErrno
- Add new builtin flag Builtin::Context::isConstWithoutErrno for
functions which can be marked as const if errno isn't respected for
math functions. Sema automatically marks these functions as const
when they are defined, if MathErrno=0.
- IRgen uses const attribute on sqrt and pow library functions to
decide if it can use the llvm intrinsic.