Commit Graph

6568 Commits

Author SHA1 Message Date
Anders Carlsson 9a020f9a3a Use IdentifierInfo * instead of std::string for the AsmStmt names.
llvm-svn: 94925
2010-01-30 22:25:16 +00:00
Daniel Dunbar 6b03ecef0d ASTUnit: Ensure the CompilerInvocation object used in LoadFromCommandLine is
live as long as the ASTUnit. This is useful for clients which want to maintain
pointers to the LangOptions object which ultimately lives in the
CompilerInvocation, although it would be nice to make all of this ownership
stuff more explicit and obvious.

llvm-svn: 94924
2010-01-30 21:47:16 +00:00
Daniel Dunbar 6824225465 CompilerInstance: Change to not contain the CompilerInvocation object.
This allows clients to install their own CompilerInvocation object, which is
important for clients that may wish to create references to things like
LangOptions whose lifetime will extend past that of the CompilerInstance.

llvm-svn: 94923
2010-01-30 21:47:07 +00:00
Anders Carlsson 66de081f39 Even more AsmStmt cleanup.
llvm-svn: 94921
2010-01-30 20:38:10 +00:00
Anders Carlsson 087bc13d96 More asm cleanup.
llvm-svn: 94920
2010-01-30 20:05:21 +00:00
Anders Carlsson 96fe0b5b96 Combine AsmStmt::setOutputsAndInputs and AsmStmt::setClobbers.
llvm-svn: 94918
2010-01-30 19:34:25 +00:00
Anders Carlsson c7c5baa482 Yay for more StringRefs.
llvm-svn: 94917
2010-01-30 19:12:25 +00:00
Anders Carlsson 0b0a122fde StringRef-ize the TargetInfo::ConstraintInfo constructor.
llvm-svn: 94916
2010-01-30 18:33:31 +00:00
Daniel Dunbar 19b70bd46c Recognize 'q' as a format length modifier (from BSD).
llvm-svn: 94894
2010-01-30 15:49:20 +00:00
Benjamin Kramer 842bf17366 Use StringRef instead of returning a temporary std::string.
This fixes a really nasty bug in Darwin::getDarwinArchName where we were going
StringRef -> temporary std::string -> StringRef (and return the dead StringRef).
The StringRefs from Triple live as long as the Triple itself, that should be
long enough.

Hopefully 2 of 4 MSVC buildbot failures are gone now.

llvm-svn: 94892
2010-01-30 15:01:47 +00:00
Benjamin Kramer f1e1e9596c Silence clang++ warning.
llvm-svn: 94878
2010-01-30 12:15:41 +00:00
Ted Kremenek c3bdff7c8c Add basic type checking of format string conversion specifiers and their arguments. Thanks to Cristian Draghici for his help with this patch!
llvm-svn: 94864
2010-01-30 00:49:51 +00:00
Ted Kremenek 79db7b7b17 Per a suggestion from Cristian Draghici, add a method to FormatSpecifier that returns the expected type of the matching data argument. It isn't complete, but should handle several of the important cases.
llvm-svn: 94851
2010-01-29 22:59:32 +00:00
Ted Kremenek 8d9842d43f Switch Sema over to using the new implementation of format string
checking.  It passes all existing tests, and the diagnostics have been
refined to provide better range information (we now highlight
individual format specifiers) and more precise wording in the
diagnostics.

llvm-svn: 94837
2010-01-29 20:55:36 +00:00
Ted Kremenek 23a71a1cdf Enhancements to the alternate (WIP) format string checking:
- Add ConversionSpecifier::consumesDataArgument() as a helper method
  to determine if a conversion specifier requires a matching argument.
- Add support for glibc-specific '%m' conversion
- Add an extra callback to HandleNull() for locations within the
  format specifier that have a null character

llvm-svn: 94834
2010-01-29 20:29:53 +00:00
Douglas Gregor d1e08648c6 Fix reference-binding when we have a reference to const volatile type;
previously, we were allowing this to bind to a temporary. Now, we
don't; add test-cases and improve diagnostics.

llvm-svn: 94831
2010-01-29 19:39:15 +00:00
Benjamin Kramer 37aa4508e2 Fix typo found by clang++. Yay for -Wuninitialized.
llvm-svn: 94810
2010-01-29 15:58:21 +00:00
Anders Carlsson 385ab187e6 Add getters.
llvm-svn: 94803
2010-01-29 06:34:33 +00:00
Anders Carlsson 5d8645b150 Simplify EmitLValueForField - we can get whether the field is part of a union or not from the FieldDecl (through its DeclContext).
llvm-svn: 94798
2010-01-29 05:05:36 +00:00
Ted Kremenek c22f78ddfd Alternate format string checking: issue warnings for incomplete format specifiers.
In addition, move ParseFormatString() and FormatStringHandler() from
the clang::analyze_printf to the clang namespace.  Hopefully this will
resolve some link errors on Linux.

llvm-svn: 94794
2010-01-29 03:16:21 +00:00
Ted Kremenek 94af575e9c Alternate format string checking: issue a warning for invalid conversion specifiers.
llvm-svn: 94792
2010-01-29 02:40:24 +00:00
Anders Carlsson ba6c437d52 Add an CXXBindReferenceExpr (not used just yet).
llvm-svn: 94791
2010-01-29 02:39:32 +00:00
John McCall 180ef09371 Do a little magic and a little greasework to make it much more efficient
to cast a DeclContext down to a specific implementation class.

There are still lots of calls to Decl::castFromDeclContext left, mostly
arising from DeclContext::getParent().

llvm-svn: 94786
2010-01-29 01:45:37 +00:00
Ted Kremenek d5fd0fac38 Alternate format string checking: warn of '%n' as being potentially insecure.
llvm-svn: 94782
2010-01-29 01:35:25 +00:00
Ted Kremenek 5739de77fa Add precision/field width checking to AlternateCheckPrintfString().
llvm-svn: 94774
2010-01-29 01:06:55 +00:00
Douglas Gregor 60b11f6dfd When printing diagnostics in c-index-test, also print source ranges
and fix-it information, so we can see everything in one place. Along
the way, fix a few bugs with deserialization and query of diagnostics
in CIndex.

llvm-svn: 94768
2010-01-29 00:41:11 +00:00
John McCall 2cb941642e Access control for surrogate function calls. Required a moderately gross hack
to get the access bits set properly in conversion sets.

llvm-svn: 94744
2010-01-28 07:38:46 +00:00
Douglas Gregor ac0605e927 Introduce serialization and deserialization of diagnostic information
so that CIndex can report diagnostics through the normal mechanisms
even when executing Clang in a separate process. This applies both
when performing code completion and when using ASTs as an intermediary
for clang_createTranslationUnitFromSourceFile().

The serialized format is not perfect at the moment, because it does
not encapsulate macro-instantiation information. Instead, it maps all
source locations back to the instantiation location. However, it does
maintain source-range and fix-it information. To get perfect fidelity
from the serialized format would require serializing a large chunk of
the source manager; at present, it isn't clear if this code will live
long enough for that to matter.

llvm-svn: 94740
2010-01-28 06:00:51 +00:00
Ted Kremenek fee0e96c82 Add position of conversion specifier character to 'ConversionSpecifier'.
llvm-svn: 94739
2010-01-28 02:46:17 +00:00
Ted Kremenek 08ad1cceb3 Rename namespace clang::printf to clang::analyze_printf to avoid problems where the reference to 'printf' is ambiguous.
llvm-svn: 94733
2010-01-28 02:02:59 +00:00
Fariborz Jahanian 81310810bd Fixes a rewrite bug rewriting nested ivars reference.
(Radar 7583971).

llvm-svn: 94724
2010-01-28 01:41:20 +00:00
Ted Kremenek bcbdaea703 Allow HandleFormatSpecifier() to indicate that no more processing of the format string is desired.
llvm-svn: 94715
2010-01-28 01:00:59 +00:00
Douglas Gregor ba965fb2a7 Switch the remaining diagnostic printing in CIndex over to the
diagnostic callback mechanism, so all diagnostics now go through that
callback. Also, eliminate the displayDiagnostics flag to
clang_createIndex(), since it is no longer necessary: the client
determines whether to display diagnostics or not.

llvm-svn: 94714
2010-01-28 00:56:43 +00:00
Ted Kremenek c06ead62f0 Add '@' conversion specifier.
llvm-svn: 94713
2010-01-28 00:55:28 +00:00
Douglas Gregor 4f9c376570 Implement a diagnostics callback for the C interface to Clang, so that
clients can format diagnostics as they wish rather than having to
parse standard error. All of the important parts of the front end's
diagnostics are exposed: text, severity, location, source ranges, and
fix-its. The diagnostics callback is now available with
clang_createTranslationUnitFromSource() and
clang_createTranslationUnit().

As part of this change, CXSourceLocation and CXSourceRange got one
pointer larger, since we need to hold on to the SourceManager and
LangOptions structures in the source location. This is the minimum
amount of information needed for the functions that operate on source
locations and ranges (as implemented now). Previously we held on to
the ASTContext, but the diagnostics callback can end up with source
locations when there is no ASTContext (or preprocessor).

Still to do:
  - Code completion needs to support the diagnostics callback, once we
  have the ability to (de-)serialize diagnostics.
  - Eliminate the "displayDiagnostics" argument to createIndex; we'll
  always pass diagnostics to the callback and let it deal with display.

llvm-svn: 94709
2010-01-28 00:27:43 +00:00
Ted Kremenek a2e77b41f3 Add skeleton for a more structured way to analyzing pring format
strings than what we currently have in Sema.  This is both an
experiment and a WIP.

The idea is simple: parse the format string incrementally,
constructing a well-structure representation of each format specifier.
Each format specifier is then handed back one-by-one to a client via a
callback.  Malformed format strings are also handled with callbacks.
The idea is to separate the parsing of the format string from the
emission of diagnostics.  Currently what we have in Sema for handling
format strings is a mongrel of both that is hard to follow and
difficult to modify (I can apply this label since I'm the original
author of that code).

This is in libAnalysis as it is reasonable generic and can potentially
be used both by libSema and libChecker.

Comments welcome.

llvm-svn: 94702
2010-01-27 23:43:25 +00:00
Ted Kremenek e9918356b2 Move more naming conventions logic out of the retain/release checker to CocoaConventions.h.
llvm-svn: 94682
2010-01-27 18:00:17 +00:00
Ken Dyck 160146eba2 Change the return type of ASTContext::getDeclAlignInBytes() to CharUnits and,
now that the "InBytes" part of the name is implied by the return type, rename
it to getDeclAlign().

llvm-svn: 94681
2010-01-27 17:10:57 +00:00
Chandler Carruth f6442e7b2e Silence a GCC warning about uninitialized variables. The first user of this
showed up with a primitive type.

llvm-svn: 94674
2010-01-27 10:28:04 +00:00
Ted Kremenek db1832d928 Start pulling out pieces of the monolithic retain/release checker into
reusable and modular API pieces.

Start by pulling the logic for deriving the Cocoa naming convention
into a separate API, header, and source file.

llvm-svn: 94662
2010-01-27 06:13:48 +00:00
Anders Carlsson 673d1401c5 It's not Explicit anymore.
llvm-svn: 94657
2010-01-27 03:27:53 +00:00
John McCall 58cc69d4c1 Implement access control for overloaded functions. Suppress access control
diagnostics in "early" lookups, such as during typename checks and when building
unresolved lookup expressions.

llvm-svn: 94647
2010-01-27 01:50:18 +00:00
Daniel Dunbar b473083fcd Support -marm by treating it as an alias for -mno-thumb.
llvm-svn: 94644
2010-01-27 01:06:14 +00:00
Daniel Dunbar b92d12622c Driver/Darwin: Disallow -m{macosx,iphoneos}-version-min as -Xarch arguments.
llvm-svn: 94636
2010-01-27 00:56:31 +00:00
Ted Kremenek 7ad29c72e3 Add const version of ObjCMethodDecl::getCanonicalDecl().
llvm-svn: 94633
2010-01-27 00:37:54 +00:00
Ted Kremenek e36bceb97d Teach RegionStore to handle initialization of incomplete arrays in structures using a compound value. Fixes <rdar://problem/7515938>.
llvm-svn: 94622
2010-01-26 23:51:00 +00:00
Ted Kremenek 6296e0990b Move 'LocalCheckers.h' to the 'Checkers' subdirectory.
llvm-svn: 94609
2010-01-26 22:59:55 +00:00
Ted Kremenek b29faead69 Move 'include/Checkers/PathSensitive/Checkers' directory to 'include/Checkers'.
llvm-svn: 94608
2010-01-26 22:56:15 +00:00
Fariborz Jahanian d59baba9fd Patch to add 'volatile' to first argument of all
sync compare_and_swap to match them with gcc.
It also fixes a few incorrect argument defitions.
(fixes radar 7540291).

llvm-svn: 94607
2010-01-26 22:48:42 +00:00
Sebastian Redl 833ef45b1d Bring some semblance of order into Decl.h and Decl.cpp. While at it, fix some typo comments and remove an unused and unimplemented function prototype. No functionality change.
llvm-svn: 94599
2010-01-26 22:01:41 +00:00