From sabre at nondot.org Mon Dec 10 00:01:34 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 10 Dec 2007 06:01:34 -0000 Subject: [cfe-commits] r44782 - /cfe/trunk/www/comparison.html Message-ID: <200712100601.lBA61YZw031858@zion.cs.uiuc.edu> Author: lattner Date: Mon Dec 10 00:01:32 2007 New Revision: 44782 URL: http://llvm.org/viewvc/llvm-project?rev=44782&view=rev Log: incorporate suggestions from Joel Nelson. Modified: cfe/trunk/www/comparison.html Modified: cfe/trunk/www/comparison.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=44782&r1=44781&r2=44782&view=diff ============================================================================== --- cfe/trunk/www/comparison.html (original) +++ cfe/trunk/www/comparison.html Mon Dec 10 00:01:32 2007 @@ -25,7 +25,11 @@

The goal of this list is to describe how differences in goals lead to different strengths and weaknesses, not to make some compiler look bad. This will hopefully help you to evaluate whether using clang is a good - idea for your specific goals.

+ idea for your personal goals. Because we don't know specifically what + you want to do, we describe the features of these compilers in + terms of our goals: if you are only interested in static + analysis, you may not care that something lacks codegen support, for + example.

Please email cfe-dev if you think we should add another compiler to this list or if you think some characterization is unfair here.

@@ -130,7 +134,10 @@
  • The Elsa community is extremely small and major development work seems to have ceased in 2005, though it continues to be used by other projects (e.g. Oink). Clang has a vibrant community including developers that - are paid to work on it full time.
  • + are paid to work on it full time. In practice this means that you can + file bugs against Clang and they will often be fixed for you. If you + use Elsa, you are (mostly) on your own for bug fixes and feature + enhancements.
  • Elsa is not built as a stack of reusable libraries like clang is. It is very difficult to use part of elsa without the whole front-end. For example, you cannot use Elsa to parse C/ObjC code without building an From sabre at nondot.org Mon Dec 10 01:14:09 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 10 Dec 2007 07:14:09 -0000 Subject: [cfe-commits] r44783 - in /cfe/trunk/www: content.css features.html index.html menu.css Message-ID: <200712100714.lBA7E9dW006545@zion.cs.uiuc.edu> Author: lattner Date: Mon Dec 10 01:14:08 2007 New Revision: 44783 URL: http://llvm.org/viewvc/llvm-project?rev=44783&view=rev Log: reorganize features, expound on a couple more. Modified: cfe/trunk/www/content.css cfe/trunk/www/features.html cfe/trunk/www/index.html cfe/trunk/www/menu.css Modified: cfe/trunk/www/content.css URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/content.css?rev=44783&r1=44782&r2=44783&view=diff ============================================================================== --- cfe/trunk/www/content.css (original) +++ cfe/trunk/www/content.css Mon Dec 10 01:14:08 2007 @@ -1,8 +1,15 @@ html, body { - margin:0px; padding:0px; } +/* Slides */ +IMG.img_slide { + display: block; + margin-left: auto; + margin-right: auto +} + + /* FIXME: This is only for the status page */ table,tr,td { border:.3ex solid black; @@ -18,46 +25,7 @@ .code { font:Courier,Arial; } -.quote { - display: block; - margin: 0 5em; -} -.key_point { - color:rgb(200,0,0); -} .simple_list { /* simple lists that don't need to stand out */ margin-left:0; } - - -/* ****************** */ -/* Performance images */ -.img_container { - display:inline; - background-color:rgb(250,250,250); - width:400px; - vertical-align:top; - margin:.1em; -} -[class=img_container] { - display:inline-block; -} -.img_container img { - display:block; -} - -.img_title { - display:block; - font-weight:bold; - color:rgb(20,50,150); -} -.img_desc .img-notes { - display:block; - padding:.3em; -} -.img_notes { - font-style:italic; - color:rgb(50,50,50); - font-size:.9em; -} -/* ****************** */ \ No newline at end of file + Modified: cfe/trunk/www/features.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/features.html?rev=44783&r1=44782&r2=44783&view=diff ============================================================================== --- cfe/trunk/www/features.html (original) +++ cfe/trunk/www/features.html Mon Dec 10 01:14:08 2007 @@ -22,15 +22,137 @@ These features are:

    +

    End-User Features:

    + + + +

    Driving Goals and Internal Design:

    +

    End-User Features

    + + + + +

    High Performance and Low Memory Use

    + + +

    A major focus of our work on clang is to make it fast, light and scalable. +The library-based architecture of clang makes it straight-forward to time and +profile the cost of each layer of the stack, and the driver has a number of +options for performance analysis.

    + +

    While there is still much that can be done, we find that the clang front-end +is significantly quicker than gcc and uses less memory For example, when +compiling "Carbon.h" on Mac OS/X, we see that clang is 2.5x faster than GCC:

    + + + +

    Carbon.h is a monster: it transitively includes 558 files, 12.3M of code, +declares 10000 functions, has 2000 struct definitions, 8000 fields, 20000 enum +constants, etc (see slide 25+ of the clang +talk for more information). It is also #include'd into almost every C file +in a GUI app on the Mac, so its compile time is very important.

    + +

    From the slide above, you can see that we can measure the time to preprocess +the file independently from the time to parse it, and independently from the +time to build the ASTs for the code. GCC doesn't provide a way to measure the +parser without AST building (it only provides -fsyntax-only). In our +measurements, we find that clang's preprocessor is consistently 40% faster than +GCCs, and the parser + AST builder is ~4x faster than GCC's. If you have +sources that do not depend as heavily on the preprocessor (or if you +use Precompiled Headers) you may see a much bigger speedup from clang. +

    + +

    Compile time performance is important, but when using clang as an API, often +memory use is even moreso: the less memory the code takes the more code you can +fit into memory at a time (useful for whole program analysis tools, for +example).

    + + + +

    Here we see a huge advantage of clang: its ASTs take 5x less memory +than GCC's syntax trees, despite the fact that clang's ASTs capture far more +source-level information than GCC's trees do. This feat is accomplished through +the use of carefully designed APIs and efficient representations.

    + +

    In addition to being efficient when pitted head-to-head against GCC in batch +mode, clang is built with a library based +architecture that makes it relatively easy to adapt it and build new tools +with it. This means that it is often possible to apply out-of-the-box thinking +and novel techniques to improve compilation in various ways.

    + + + +

    This slide shows how the clang preprocessor can be used to make "distcc" +parallelization 3x more scalable than when using the GCC preprocessor. +"distcc" quickly bottlenecks on the preprocessor running on the central driver +machine, so a fast preprocessor is very useful. Comparing the first two bars +of each group shows how a ~40% faster preprocessor can reduce preprocessing time +of these large C++ apps by about 40% (shocking!).

    + +

    The third bar on the slide is the interesting part: it shows how trivial +caching of file system accesses across invocations of the preprocessor allows +clang to reduce time spent in the kernel by 10x, making distcc over 3x more +scalable. This is obviously just one simple hack, doing more interesting things +(like caching tokens across preprocessed files) would yield another substantial +speedup.

    + +

    The clean framework-based design of clang means that many things are possible +that would be very difficult in other systems, for example incremental +compilation, multithreading, intelligent caching, etc. We are only starting +to tap the full potential of the clang design.

    + + + +

    Expressive Diagnostics

    + + +

    Clang is designed to efficiently capture range information for expressions +and statements, which allows it to emit very useful and detailed diagnostic +information (e.g. warnings and errors) when a problem is detected.

    + +

    For example, this slide compares the diagnostics emitted by clang (top) to +the diagnostics emitted by GCC (middle) for a simple example:

    + + + +

    As you can see, clang goes beyond tracking just column number information: it +is able to highlight the subexpressions involved in a problem, making it much +easier to understand the source of the problem in many cases. For example, in +the first problem, it tells you why the operand is invalid (it +requires a pointer) and what type it really is.

    + +

    In the second error, you can see how clang uses column number information to +identify exactly which "+" out of the four on that line is causing the problem. +Further, it highlights the subexpressions involved, which can be very useful +when a complex subexpression that relies on tricky precedence rules.

    + +

    The example doesn't show it, but clang works very hard to retain typedef +information, ensuring that diagnostics print the user types, not the fully +expanded (and often huge) types. This is clearly important for C++ code (tell +me about "std::string", not about "std::basic_string<char, +std::char_traits<char>, std::allocator<char> >"!), but it is +also very useful in C code in some cases as well (e.g. "__m128" vs +"float __attribute__((__vector_size__(16)))").

    + + + +

    Driving Goals and Internal Design

    + + +

    A real-world, production quality compiler

    @@ -88,11 +210,36 @@ C, C++'03, Objective-C 2, etc.

    -

    Library based architecture

    +

    GCC Compatibility

    + + +

    GCC is currently the defacto-standard open source compiler today, and it +routinely compiles a huge volume of code. GCC supports a huge number of +extensions and features (many of which are undocumented) and a lot of +code and header files depend on these features in order to build.

    + +

    While it would be nice to be able to ignore these extensions and focus on +implementing the language standards to the letter, pragmatics force us to +support the GCC extensions that see the most use. As mentioned above, all +extensions are explicitly recognized as such and marked with extension +diagnostics, which can be mapped to warnings, errors, or just ignored. +

    + + + +

    Library based architecture

    A major design concept for the LLVM front-end involves using a library based architecture. In this library based architecture, various parts of the front-end can be cleanly divided into separate libraries which can then be mixed up for different needs and uses. In addition, the library based approach makes it much easier for new developers to get involved and extend LLVM to do new and unique things. In the words of Chris, -
    "The world needs better compiler tools, tools which are built as libraries. This design point allows reuse of the tools in new and novel ways. However, building the tools as libraries isn't enough: they must have clean APIs, be as decoupled from each other as possible, and be easy to modify/extend. This requires clean layering, decent design, and keeping the libraries independent of any specific client."
    + +
    +"The world needs better compiler tools, tools which are built as libraries. +This design point allows reuse of the tools in new and novel ways. However, +building the tools as libraries isn't enough: they must have clean APIs, be as +decoupled from each other as possible, and be easy to modify/extend. This +requires clean layering, decent design, and keeping the libraries independent of +any specific client."
    + Currently, the LLVM front-end is divided into the following libraries:

    Of course this is only a rough outline of the goals and features of - Clang. To get a true sense of what the new LLVM front-end is all about, - as well as why you might want to considering using it, see the Features section.

    + Clang. To get a true sense of what it is all about, see the Features section. The Features section breaks + each of these down and explains them in more detail.

    Why?

    @@ -58,7 +58,7 @@

    The development of a new front-end was started out of a need -- a need for a compiler that allows better diagnostics, better integration with IDEs, a license that is compatible with commercial products, and a - compiler that is easier to develop and maintain. All of these were + nimble compiler that is easy to develop and maintain. All of these were motivations for starting work on a new front-end that could meet these needs.

    Modified: cfe/trunk/www/menu.css URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/menu.css?rev=44783&r1=44782&r2=44783&view=diff ============================================================================== --- cfe/trunk/www/menu.css (original) +++ cfe/trunk/www/menu.css Mon Dec 10 01:14:08 2007 @@ -23,10 +23,6 @@ /* menu style */ /**************/ -#menu { - padding-left: .3em; -} - #menu .submenu { padding-top:1em; display:block; From sabre at nondot.org Mon Dec 10 01:23:53 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 10 Dec 2007 07:23:53 -0000 Subject: [cfe-commits] r44784 - in /cfe/trunk/www: comparison.html features.html Message-ID: <200712100723.lBA7NrCQ007246@zion.cs.uiuc.edu> Author: lattner Date: Mon Dec 10 01:23:52 2007 New Revision: 44784 URL: http://llvm.org/viewvc/llvm-project?rev=44784&view=rev Log: now with hackability. Modified: cfe/trunk/www/comparison.html cfe/trunk/www/features.html Modified: cfe/trunk/www/comparison.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=44784&r1=44783&r2=44784&view=diff ============================================================================== --- cfe/trunk/www/comparison.html (original) +++ cfe/trunk/www/comparison.html Mon Dec 10 01:23:52 2007 @@ -60,7 +60,8 @@

    Pro's of clang vs GCC:

    -

    End-User Features

    +

    End-User Features

    @@ -183,7 +183,7 @@ -

    Utility and Applications

    +

    Utility and Applications

    @@ -338,7 +338,7 @@ -

    Internal Design and Implementation

    +

    Internal Design and Implementation

    Modified: cfe/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/index.html?rev=44788&r1=44787&r2=44788&view=diff ============================================================================== --- cfe/trunk/www/index.html (original) +++ cfe/trunk/www/index.html Mon Dec 10 02:19:29 2007 @@ -9,95 +9,107 @@ - -
    -

    clang: a C language family frontend for LLVM

    - -

    The goal of the Clang project is to create a new C, C++, Objective C and - Objective C++ front-end for the LLVM - compiler.

    - -

    Features and Goals

    - -

    Some of the goals for the project include the following:

    - - - -

    Of course this is only a rough outline of the goals and features of - Clang. To get a true sense of what it is all about, see the Features section. The Features section breaks - each of these down and explains them in more detail.

    - - -

    Why?

    - -

    The development of a new front-end was started out of a need -- a need - for a compiler that allows better diagnostics, better integration with - IDEs, a license that is compatible with commercial products, and a - nimble compiler that is easy to develop and maintain. All of these were - motivations for starting work on a new front-end that could - meet these needs.

    - -

    A good (but quite dated) introduction to Clang can be found in the - following video lectures:

    - - - -

    For a more detailed comparison between Clang and other compilers, please - see the clang comparison page.

    - -

    Current Status

    - -

    Clang is still in early development stages. If you are looking for - source analysis or source-to-source transformation tools, clang is probably - a great solution for you. If you want to use it as a drop in C compiler, it - is not yet ready.

    - -

    Clang currently has pretty good parsing and semantic analysis support for - C and Objective-C right now, and bugs are usually quickly fixed once - reported. C++ support is still very early, and we don't expect to have - respectable C++ support for another 2 years or so.

    - -

    Get Involved

    - -

    The developers of Clang include contributers from Apple and numerous - other volunteers. If you are interested in joining the community or - learning more, please consider joining the cfe-dev - mailing list, or start by browsing its archives.

    - -

    If you are interested in trying out Clang, please see the build - instructions on the Get Involved - page.

    -
    + +
    + +

    clang: a C language family frontend for LLVM

    + + +

    The goal of the Clang project is to create a new C, C++, Objective C and + Objective C++ front-end for the LLVM + compiler.

    + + +

    Features and Goals

    + + +

    Some of the goals for the project include the following:

    + +

    End-User Features:

    + + + +

    Utility and + Applications:

    + + + +

    Internal Design and + Implementation:

    + + + +

    Of course this is only a rough outline of the goals and features of + Clang. To get a true sense of what it is all about, see the Features section, which breaks + each of these down and explains them in more detail.

    + + + +

    Why?

    + + +

    The development of a new front-end was started out of a need -- a need + for a compiler that allows better diagnostics, better integration with + IDEs, a license that is compatible with commercial products, and a + nimble compiler that is easy to develop and maintain. All of these were + motivations for starting work on a new front-end that could + meet these needs.

    + +

    A good (but quite dated) introduction to Clang can be found in the + following video lectures:

    + + + +

    For a more detailed comparison between Clang and other compilers, please + see the clang comparison page.

    + + +

    Current Status

    + + +

    Clang is still in early development stages. If you are looking for + source analysis or source-to-source transformation tools, clang is probably + a great solution for you. If you want to use it as a drop in C compiler, it + is not yet ready.

    + +

    Clang currently has pretty good parsing and semantic analysis support for + C and Objective-C right now, and bugs are usually quickly fixed once + reported. C++ support is still very early, and we don't expect to have + respectable C++ support for another 2 years or so.

    + + +

    Get Involved

    + + +

    The developers of Clang include contributers from Apple and numerous + other volunteers. If you are interested in joining the community or + learning more, please consider joining the cfe-dev + mailing list, or start by browsing its archives.

    + +

    If you are interested in trying out Clang, please see the build + instructions on the Get Involved + page.

    +
    From sabre at nondot.org Mon Dec 10 02:21:13 2007 From: sabre at nondot.org (Chris Lattner) Date: Mon, 10 Dec 2007 08:21:13 -0000 Subject: [cfe-commits] r44789 - /cfe/trunk/www/comparison.html Message-ID: <200712100821.lBA8LD1h013535@zion.cs.uiuc.edu> Author: lattner Date: Mon Dec 10 02:21:12 2007 New Revision: 44789 URL: http://llvm.org/viewvc/llvm-project?rev=44789&view=rev Log: fixes, thanks to Nico Weber Modified: cfe/trunk/www/comparison.html Modified: cfe/trunk/www/comparison.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=44789&r1=44788&r2=44789&view=diff ============================================================================== --- cfe/trunk/www/comparison.html (original) +++ cfe/trunk/www/comparison.html Mon Dec 10 02:21:12 2007 @@ -62,7 +62,7 @@ From sabre at nondot.org Tue Dec 11 16:23:00 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 11 Dec 2007 22:23:00 -0000 Subject: [cfe-commits] r44882 - /cfe/trunk/www/comparison.html Message-ID: <200712112223.lBBMN0Ax029802@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 11 16:22:59 2007 New Revision: 44882 URL: http://llvm.org/viewvc/llvm-project?rev=44882&view=rev Log: add a con of clang vs gcc Modified: cfe/trunk/www/comparison.html Modified: cfe/trunk/www/comparison.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=44882&r1=44881&r2=44882&view=diff ============================================================================== --- cfe/trunk/www/comparison.html (original) +++ cfe/trunk/www/comparison.html Tue Dec 11 16:22:59 2007 @@ -53,6 +53,9 @@
  • GCC front-ends are very mature and already support C/C++/ObjC and all the variants we are interested in. clang's support for C++ in particular is nowhere near what GCC supports.
  • +
  • GCC's codegen is much more mature than clang's right now. clang is + only capable of codegen for small and simple projects and does not yet + support debug info.
  • GCC is popular and widely adopted.
  • GCC does not require a C++ compiler to build it.
  • From sabre at nondot.org Tue Dec 11 16:26:03 2007 From: sabre at nondot.org (Chris Lattner) Date: Tue, 11 Dec 2007 22:26:03 -0000 Subject: [cfe-commits] r44883 - /cfe/trunk/www/comparison.html Message-ID: <200712112226.lBBMQ3uN003690@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 11 16:26:03 2007 New Revision: 44883 URL: http://llvm.org/viewvc/llvm-project?rev=44883&view=rev Log: improve title Modified: cfe/trunk/www/comparison.html Modified: cfe/trunk/www/comparison.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=44883&r1=44882&r2=44883&view=diff ============================================================================== --- cfe/trunk/www/comparison.html (original) +++ cfe/trunk/www/comparison.html Tue Dec 11 16:26:03 2007 @@ -4,14 +4,14 @@ - Comparing clang to other compilers + Comparing clang to other open source compilers
    -

    Clang vs Other Compilers

    +

    Clang vs Other Open Source Compilers

    Building an entirely new compiler front-end is a big task, and it isn't always clear to people why we decided to do this. Here we compare clang From sabre at nondot.org Tue Dec 11 21:33:42 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 03:33:42 -0000 Subject: [cfe-commits] r44906 - /cfe/trunk/www/comparison.html Message-ID: <200712120333.lBC3XhqC025860@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 11 21:33:41 2007 New Revision: 44906 URL: http://llvm.org/viewvc/llvm-project?rev=44906&view=rev Log: fix typo pointed out by gordon Modified: cfe/trunk/www/comparison.html Modified: cfe/trunk/www/comparison.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=44906&r1=44905&r2=44906&view=diff ============================================================================== --- cfe/trunk/www/comparison.html (original) +++ cfe/trunk/www/comparison.html Tue Dec 11 21:33:41 2007 @@ -94,7 +94,7 @@ example, if you write "x-x" in your source code, the GCC AST will contain "0", with no mention of 'x'. This is extremely bad for a refactoring tool that wants to rename 'x'. -

  • Clang can serialize it's AST out to disk and read it back into another +
  • Clang can serialize its AST out to disk and read it back into another program, which is useful for whole program analysis. GCC does not have this, but its current PCH mechanism is close. However, GCC's current PCH support is architecturally only able to read the dump back into From sabre at nondot.org Tue Dec 11 22:13:21 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 04:13:21 -0000 Subject: [cfe-commits] r44908 - in /cfe/trunk: CodeGen/CGExprScalar.cpp clang.xcodeproj/project.pbxproj test/CodeGen/cast.c Message-ID: <200712120413.lBC4DLGs030225@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 11 22:13:20 2007 New Revision: 44908 URL: http://llvm.org/viewvc/llvm-project?rev=44908&view=rev Log: Fix a codegen crash on test/CodeGen/cast.c, reported by Keith. Added: cfe/trunk/test/CodeGen/cast.c Modified: cfe/trunk/CodeGen/CGExprScalar.cpp cfe/trunk/clang.xcodeproj/project.pbxproj Modified: cfe/trunk/CodeGen/CGExprScalar.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=44908&r1=44907&r2=44908&view=diff ============================================================================== --- cfe/trunk/CodeGen/CGExprScalar.cpp (original) +++ cfe/trunk/CodeGen/CGExprScalar.cpp Tue Dec 11 22:13:20 2007 @@ -512,7 +512,17 @@ llvm::Constant *Idx0 = llvm::ConstantInt::get(llvm::Type::Int32Ty, 0); llvm::Value *Ops[] = {Idx0, Idx0}; - return Builder.CreateGEP(V, Ops, Ops+2, "arraydecay"); + V = Builder.CreateGEP(V, Ops, Ops+2, "arraydecay"); + + // The resultant pointer type can be implicitly casted to other pointer + // types as well, for example void*. + const llvm::Type *DestPTy = ConvertType(E->getType()); + assert(isa(DestPTy) && + "Only expect implicit cast to pointer"); + if (V->getType() != DestPTy) + V = Builder.CreateBitCast(V, DestPTy, "ptrconv"); + return V; + } else if (E->getType()->isReferenceType()) { assert(cast(E->getType().getCanonicalType())-> getReferenceeType() == Modified: cfe/trunk/clang.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=44908&r1=44907&r2=44908&view=diff ============================================================================== --- cfe/trunk/clang.xcodeproj/project.pbxproj (original) +++ cfe/trunk/clang.xcodeproj/project.pbxproj Tue Dec 11 22:13:20 2007 @@ -772,6 +772,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; + compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; Added: cfe/trunk/test/CodeGen/cast.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cast.c?rev=44908&view=auto ============================================================================== --- cfe/trunk/test/CodeGen/cast.c (added) +++ cfe/trunk/test/CodeGen/cast.c Tue Dec 11 22:13:20 2007 @@ -0,0 +1,6 @@ +// RUN: clang %s -emit-llvm + +extern void go(const void *p); +float v[2] = { 0.0, 1.0 }; +void foo(void) { go(v); } + From sabre at nondot.org Tue Dec 11 22:22:38 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 04:22:38 -0000 Subject: [cfe-commits] r44909 - /cfe/trunk/www/comparison.html Message-ID: <200712120422.lBC4Mcax031066@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 11 22:22:37 2007 New Revision: 44909 URL: http://llvm.org/viewvc/llvm-project?rev=44909&view=rev Log: typo reported by Gabor Greif Modified: cfe/trunk/www/comparison.html Modified: cfe/trunk/www/comparison.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=44909&r1=44908&r2=44909&view=diff ============================================================================== --- cfe/trunk/www/comparison.html (original) +++ cfe/trunk/www/comparison.html Tue Dec 11 22:22:37 2007 @@ -162,7 +162,7 @@

    Note that there is a fork of Elsa known as "Pork". It addresses some of - these shortcomings by loosly integrating a preprocessor. This allows it + these shortcomings by loosely integrating a preprocessor. This allows it to map from a source location in the AST to the original position before preprocessing, providing it better support for static analysis and refactoring. For more details, please see the Pork page.

    From sabre at nondot.org Tue Dec 11 23:01:48 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 05:01:48 -0000 Subject: [cfe-commits] r44911 - /cfe/trunk/Driver/clang.cpp Message-ID: <200712120501.lBC51mOn001297@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 11 23:01:48 2007 New Revision: 44911 URL: http://llvm.org/viewvc/llvm-project?rev=44911&view=rev Log: Simplify some code, don't force the triple to a darwin triple if non-darwin. Modified: cfe/trunk/Driver/clang.cpp Modified: cfe/trunk/Driver/clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=44911&r1=44910&r2=44911&view=diff ============================================================================== --- cfe/trunk/Driver/clang.cpp (original) +++ cfe/trunk/Driver/clang.cpp Tue Dec 11 23:01:48 2007 @@ -426,38 +426,27 @@ } static void CreateTargetTriples(std::vector& triples) { - std::string base_triple; - // Initialize base triple. If a -triple option has been specified, use // that triple. Otherwise, default to the host triple. - if (TargetTriple.getValue().empty()) { - // HACK: For non-darwin systems, we don't have any real target support - // yet. For these systems, set the target to darwin. - if (!strstr(LLVM_HOSTTRIPLE,"darwin")) - base_triple = "i386-apple-darwin"; - else - base_triple = LLVM_HOSTTRIPLE; - } - else - base_triple = TargetTriple.getValue(); + std::string Triple = TargetTriple; + if (Triple.empty()) Triple = LLVM_HOSTTRIPLE; // Decompose the base triple into "arch" and suffix. - std::string::size_type firstDash = base_triple.find("-"); + std::string::size_type firstDash = Triple.find("-"); if (firstDash == std::string::npos) { fprintf(stderr, "Malformed target triple: \"%s\" ('-' could not be found).\n", - base_triple.c_str()); - exit (1); + Triple.c_str()); + exit(1); } - std::string suffix(base_triple,firstDash+1); + std::string suffix(Triple, firstDash+1); if (suffix.empty()) { - fprintf(stderr, - "Malformed target triple: \"%s\" (no vendor or OS).\n", - base_triple.c_str()); - exit (1); + fprintf(stderr, "Malformed target triple: \"%s\" (no vendor or OS).\n", + Triple.c_str()); + exit(1); } // Create triple cacher. @@ -466,7 +455,7 @@ // Add the primary triple to our set of triples if we are using the // host-triple with no archs or using a specified target triple. if (!TargetTriple.getValue().empty() || Archs.empty()) - tp.addTriple(base_triple); + tp.addTriple(Triple); for (unsigned i = 0, e = Archs.size(); i !=e; ++i) tp.addTriple(Archs[i] + "-" + suffix); From sabre at nondot.org Tue Dec 11 23:47:29 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 05:47:29 -0000 Subject: [cfe-commits] r44912 - in /cfe/trunk/Sema: Sema.h SemaExpr.cpp Message-ID: <200712120547.lBC5lTVp006905@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 11 23:47:28 2007 New Revision: 44912 URL: http://llvm.org/viewvc/llvm-project?rev=44912&view=rev Log: implement correct semantic analysis for shifts. For: int test(int x, long long y) { return x << y; } we now realize the type of the shift is int, not long long. This fixes a fixme from june. Modified: cfe/trunk/Sema/Sema.h cfe/trunk/Sema/SemaExpr.cpp Modified: cfe/trunk/Sema/Sema.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=44912&r1=44911&r2=44912&view=diff ============================================================================== --- cfe/trunk/Sema/Sema.h (original) +++ cfe/trunk/Sema/Sema.h Tue Dec 11 23:47:28 2007 @@ -631,7 +631,7 @@ /// or a null QualType (indicating an error diagnostic was issued). /// type checking binary operators (subroutines of ActOnBinOp). - inline void InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex); + inline QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex); inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex); inline QualType CheckMultiplyDivideOperands( // C99 6.5.5 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); Modified: cfe/trunk/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=44912&r1=44911&r2=44912&view=diff ============================================================================== --- cfe/trunk/Sema/SemaExpr.cpp (original) +++ cfe/trunk/Sema/SemaExpr.cpp Tue Dec 11 23:47:28 2007 @@ -1176,10 +1176,11 @@ return CheckAssignmentConstraints(lhsType, rhsType); } -inline void Sema::InvalidOperands(SourceLocation loc, Expr *&lex, Expr *&rex) { +QualType Sema::InvalidOperands(SourceLocation loc, Expr *&lex, Expr *&rex) { Diag(loc, diag::err_typecheck_invalid_operands, lex->getType().getAsString(), rex->getType().getAsString(), lex->getSourceRange(), rex->getSourceRange()); + return QualType(); } inline QualType Sema::CheckVectorOperands(SourceLocation loc, Expr *&lex, @@ -1208,8 +1209,7 @@ if (lex->getType()->isArithmeticType() && rex->getType()->isArithmeticType()) return compType; - InvalidOperands(loc, lex, rex); - return QualType(); + return InvalidOperands(loc, lex, rex); } inline QualType Sema::CheckRemainderOperands( @@ -1221,8 +1221,7 @@ if (lex->getType()->isIntegerType() && rex->getType()->isIntegerType()) return compType; - InvalidOperands(loc, lex, rex); - return QualType(); + return InvalidOperands(loc, lex, rex); } inline QualType Sema::CheckAdditionOperands( // C99 6.5.6 @@ -1241,8 +1240,7 @@ return lex->getType(); if (lex->getType()->isIntegerType() && rex->getType()->isPointerType()) return rex->getType(); - InvalidOperands(loc, lex, rex); - return QualType(); + return InvalidOperands(loc, lex, rex); } inline QualType Sema::CheckSubtractionOperands( // C99 6.5.6 @@ -1307,22 +1305,22 @@ } } - InvalidOperands(loc, lex, rex); - return QualType(); + return InvalidOperands(loc, lex, rex); } inline QualType Sema::CheckShiftOperands( // C99 6.5.7 - Expr *&lex, Expr *&rex, SourceLocation loc, bool isCompAssign) -{ - // FIXME: Shifts don't perform usual arithmetic conversions. This is wrong - // for int << longlong -> the result type should be int, not long long. - QualType compType = UsualArithmeticConversions(lex, rex, isCompAssign); + Expr *&lex, Expr *&rex, SourceLocation loc, bool isCompAssign) { + // C99 6.5.7p2: Each of the operands shall have integer type. + if (!lex->getType()->isIntegerType() || !rex->getType()->isIntegerType()) + return InvalidOperands(loc, lex, rex); - // handle the common case first (both operands are arithmetic). - if (lex->getType()->isIntegerType() && rex->getType()->isIntegerType()) - return compType; - InvalidOperands(loc, lex, rex); - return QualType(); + // Shifts don't perform usual arithmetic conversions, they just do integer + // promotions on each operand. C99 6.5.7p3 + UsualUnaryConversions(lex); + UsualUnaryConversions(rex); + + // "The type of the result is that of the promoted left operand." + return lex->getType(); } inline QualType Sema::CheckCompareOperands( // C99 6.5.8 @@ -1398,8 +1396,7 @@ promoteExprToType(lex, rType); // promote the integer to pointer return Context.IntTy; } - InvalidOperands(loc, lex, rex); - return QualType(); + return InvalidOperands(loc, lex, rex); } inline QualType Sema::CheckBitwiseOperands( @@ -1412,8 +1409,7 @@ if (lex->getType()->isIntegerType() && rex->getType()->isIntegerType()) return compType; - InvalidOperands(loc, lex, rex); - return QualType(); + return InvalidOperands(loc, lex, rex); } inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14] @@ -1424,8 +1420,7 @@ if (lex->getType()->isScalarType() || rex->getType()->isScalarType()) return Context.IntTy; - InvalidOperands(loc, lex, rex); - return QualType(); + return InvalidOperands(loc, lex, rex); } inline QualType Sema::CheckAssignmentOperands( // C99 6.5.16.1 From clattner at apple.com Wed Dec 12 00:05:22 2007 From: clattner at apple.com (Chris Lattner) Date: Tue, 11 Dec 2007 22:05:22 -0800 Subject: [cfe-commits] r43534 - in /cfe/trunk: Sema/SemaDecl.cpp clang.xcodeproj/project.pbxproj include/clang/AST/Decl.h include/clang/AST/DeclObjC.h In-Reply-To: <200710310012.l9V0CZW6004188@zion.cs.uiuc.edu> References: <200710310012.l9V0CZW6004188@zion.cs.uiuc.edu> Message-ID: <4720021F-6D3C-4039-B289-E4B4BFD916E8@apple.com> On Oct 30, 2007, at 5:12 PM, Fariborz Jahanian wrote: > Author: fjahanian > Date: Tue Oct 30 19:12:35 2007 > New Revision: 43534 > > Added new type and bitfield fields in some decl types in preparation > for objective-c's type qualifiers. > Added initialization of Class/SEMA types. Hi Fariborz, This patch adds ObjcDeclQualifier to VarDecl. Doesn't it make more sense for them to be on ParmVarDecl? -Chris > + /// ObjcDeclQualifier - Qualifier used on types in method > declarations > + /// for remote messaging. They are meant for the arguments though > and > + /// applied to the Decls (ObjcMethodDecl and ParmVarDecl). > + enum ObjcDeclQualifier { > + OBJC_TQ_None = 0x0, > + OBJC_TQ_In = 0x1, > + OBJC_TQ_Inout = 0x2, > + OBJC_TQ_Out = 0x4, > + OBJC_TQ_Bycopy = 0x8, > + OBJC_TQ_Byref = 0x10, > + OBJC_TQ_Oneway = 0x20 > + }; > + > private: > /// Loc - The location that this decl. > SourceLocation Loc; > @@ -280,6 +293,8 @@ > // as static variables declared within a function. > bool hasGlobalStorage() const { return !hasAutoStorage(); } > > + ObjcDeclQualifier getObjcDeclQualifier() const { return > objcDeclQualifier; } > + > // Implement isa/cast/dyncast/etc. > static bool classof(const Decl *D) { > return D->getKind() >= VarFirst && D->getKind() <= VarLast; > @@ -288,11 +303,16 @@ > protected: > VarDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T, > StorageClass SC, ScopedDecl *PrevDecl) > - : ValueDecl(DK, L, Id, T, PrevDecl), Init(0) { SClass = SC; } > + : ValueDecl(DK, L, Id, T, PrevDecl), Init(0), > + objcDeclQualifier(OBJC_TQ_None) { SClass = SC; } > private: > Expr *Init; > // FIXME: This can be packed into the bitfields in Decl. > unsigned SClass : 3; > + /// FIXME: Also can be paced into the bitfields in Decl. > + /// in, inout, etc. > + ObjcDeclQualifier objcDeclQualifier : 6; > + > friend class StmtIteratorBase; > }; > > > Modified: cfe/trunk/include/clang/AST/DeclObjC.h > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=43534&r1=43533&r2=43534&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- cfe/trunk/include/clang/AST/DeclObjC.h (original) > +++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Oct 30 19:12:35 2007 > @@ -218,6 +218,9 @@ > /// @required/@optional > ImplementationControl DeclImplementation : 2; > > + /// in, inout, etc. > + ObjcDeclQualifier objcDeclQualifier : 6; > + > // A unigue name for this method. > Selector SelName; > > @@ -241,11 +244,14 @@ > Decl *PrevDecl = 0) > : Decl(ObjcMethod, beginLoc), > IsInstance(isInstance), DeclImplementation(impControl), > + objcDeclQualifier(OBJC_TQ_None), > SelName(SelInfo), MethodDeclType(T), > ParamInfo(paramInfo), NumMethodParams(numParams), > MethodAttrs(M), EndLoc(endLoc) {} > virtual ~ObjcMethodDecl(); > > + ObjcDeclQualifier getObjcDeclQualifier() const { return > objcDeclQualifier; } > + > // Location information, modeled after the Stmt API. > SourceLocation getLocStart() const { return getLocation(); } > SourceLocation getLocEnd() const { return EndLoc; } > > > _______________________________________________ > cfe-commits mailing list > cfe-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits From sabre at nondot.org Wed Dec 12 00:13:27 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 06:13:27 -0000 Subject: [cfe-commits] r44913 - /cfe/trunk/Parse/ParseDecl.cpp Message-ID: <200712120613.lBC6DREN008357@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 00:13:27 2007 New Revision: 44913 URL: http://llvm.org/viewvc/llvm-project?rev=44913&view=rev Log: simplify some code. Modified: cfe/trunk/Parse/ParseDecl.cpp Modified: cfe/trunk/Parse/ParseDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseDecl.cpp?rev=44913&r1=44912&r2=44913&view=diff ============================================================================== --- cfe/trunk/Parse/ParseDecl.cpp (original) +++ cfe/trunk/Parse/ParseDecl.cpp Wed Dec 12 00:13:27 2007 @@ -556,51 +556,33 @@ /// qualifier list and builds their bitmask representation in the input /// argument. void Parser::ParseObjcTypeQualifierList(ObjcDeclSpec &DS) { - bool found = true; - while (found) { - found = false; - if (Tok.is(tok::identifier)) { - const IdentifierInfo *II = Tok.getIdentifierInfo(); - unsigned i; - for (i = 0; i < objc_NumQuals; ++i) { - if (II == ObjcTypeQuals[i]) { - switch (i) { - case objc_in: - DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_In); - ConsumeToken(); - found = true; - break; - case objc_out: - DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Out); - ConsumeToken(); - found = true; - break; - case objc_inout: - DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Inout); - ConsumeToken(); - found = true; - break; - case objc_oneway: - DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Oneway); - ConsumeToken(); - found = true; - break; - case objc_bycopy: - DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Bycopy); - ConsumeToken(); - found = true; - break; - case objc_byref: - DS.setObjcDeclQualifier(ObjcDeclSpec::DQ_Byref); - ConsumeToken(); - found = true; - break; - } - if (found) - break; - } + while (1) { + if (!Tok.is(tok::identifier)) + return; + + const IdentifierInfo *II = Tok.getIdentifierInfo(); + for (unsigned i = 0; i != objc_NumQuals; ++i) { + if (II != ObjcTypeQuals[i]) + continue; + + ObjcDeclSpec::ObjcDeclQualifier Qual; + switch (i) { + default: assert(0 && "Unknown decl qualifier"); + case objc_in: Qual = ObjcDeclSpec::DQ_In; break; + case objc_out: Qual = ObjcDeclSpec::DQ_Out; break; + case objc_inout: Qual = ObjcDeclSpec::DQ_Inout; break; + case objc_oneway: Qual = ObjcDeclSpec::DQ_Oneway; break; + case objc_bycopy: Qual = ObjcDeclSpec::DQ_Bycopy; break; + case objc_byref: Qual = ObjcDeclSpec::DQ_Byref; break; } + DS.setObjcDeclQualifier(Qual); + ConsumeToken(); + II = 0; + break; } + + // If this wasn't a recognized qualifier, bail out. + if (II) return; } } From sabre at nondot.org Wed Dec 12 00:19:30 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 06:19:30 -0000 Subject: [cfe-commits] r44915 - /cfe/trunk/test/TestRunner.sh Message-ID: <200712120619.lBC6JUec008959@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 00:19:22 2007 New Revision: 44915 URL: http://llvm.org/viewvc/llvm-project?rev=44915&view=rev Log: verify that tests contain RUN lines. Modified: cfe/trunk/test/TestRunner.sh Modified: cfe/trunk/test/TestRunner.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/TestRunner.sh?rev=44915&r1=44914&r2=44915&view=diff ============================================================================== --- cfe/trunk/test/TestRunner.sh (original) +++ cfe/trunk/test/TestRunner.sh Wed Dec 12 00:19:22 2007 @@ -33,8 +33,14 @@ ulimit -t 40 +# Verify the script contains a run line. +grep -q 'RUN:' $FILENAME || ( + echo "******************** TEST '$TESTNAME' HAS NO RUN LINE! ********************" + exit 1 +) + SCRIPT=$OUTPUT.script -grep 'RUN:' $FILENAME | sed "s|^.*RUN:\(.*\)$|\1|g;s|%s|$SUBST|g;s|%llvmgcc|llvm-gcc -emit-llvm|g;s|%llvmgxx|llvm-g++ -emit-llvm|g;s|%prcontext|prcontext.tcl|g" > $SCRIPT +grep 'RUN:' $FILENAME | sed "s|^.*RUN:\(.*\)$|\1|g;s|%s|$SUBST|g;s|%llvmgcc|llvm-gcc -emit-llvm|g;s|%llvmgxx|llvm-g++ -emit-llvm|g;s|%prcontext|prcontext.tcl|g" > $SCRIPT grep -q XFAIL $FILENAME && (printf "XFAILED '$TESTNAME': "; grep XFAIL $FILENAME) From sabre at nondot.org Wed Dec 12 00:20:19 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 06:20:19 -0000 Subject: [cfe-commits] r44916 - /cfe/trunk/test/Preprocessor/macro_paste_simple.c Message-ID: <200712120620.lBC6KJDH009015@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 00:20:18 2007 New Revision: 44916 URL: http://llvm.org/viewvc/llvm-project?rev=44916&view=rev Log: add runline, make this test real. Modified: cfe/trunk/test/Preprocessor/macro_paste_simple.c Modified: cfe/trunk/test/Preprocessor/macro_paste_simple.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_paste_simple.c?rev=44916&r1=44915&r2=44916&view=diff ============================================================================== --- cfe/trunk/test/Preprocessor/macro_paste_simple.c (original) +++ cfe/trunk/test/Preprocessor/macro_paste_simple.c Wed Dec 12 00:20:18 2007 @@ -1,3 +1,5 @@ -// clang %s -E | grep "barbaz123" +// RUN: clang %s -E | grep "barbaz123" #define FOO bar ## baz ## 123 + +FOO From sabre at nondot.org Wed Dec 12 00:20:41 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 06:20:41 -0000 Subject: [cfe-commits] r44917 - /cfe/trunk/test/Preprocessor/macro_rparen_scan2.c Message-ID: <200712120620.lBC6Kf3n009043@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 00:20:40 2007 New Revision: 44917 URL: http://llvm.org/viewvc/llvm-project?rev=44917&view=rev Log: add run line Modified: cfe/trunk/test/Preprocessor/macro_rparen_scan2.c Modified: cfe/trunk/test/Preprocessor/macro_rparen_scan2.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_rparen_scan2.c?rev=44917&r1=44916&r2=44917&view=diff ============================================================================== --- cfe/trunk/test/Preprocessor/macro_rparen_scan2.c (original) +++ cfe/trunk/test/Preprocessor/macro_rparen_scan2.c Wed Dec 12 00:20:40 2007 @@ -1,4 +1,4 @@ -// clang -E %s | grep -F 'static int glob = (1 + 1 );' +// RUN: clang -E %s | grep -F 'static int glob = (1 + 1 );' #define R_PAREN ) From sabre at nondot.org Wed Dec 12 00:22:14 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 06:22:14 -0000 Subject: [cfe-commits] r44918 - in /cfe/trunk/test/Sema: invalid-decl.c method-def-1.m Message-ID: <200712120622.lBC6MEo6009106@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 00:22:14 2007 New Revision: 44918 URL: http://llvm.org/viewvc/llvm-project?rev=44918&view=rev Log: add run lines. Modified: cfe/trunk/test/Sema/invalid-decl.c cfe/trunk/test/Sema/method-def-1.m Modified: cfe/trunk/test/Sema/invalid-decl.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/invalid-decl.c?rev=44918&r1=44917&r2=44918&view=diff ============================================================================== --- cfe/trunk/test/Sema/invalid-decl.c (original) +++ cfe/trunk/test/Sema/invalid-decl.c Wed Dec 12 00:22:14 2007 @@ -1,3 +1,4 @@ +// RUN: clang %s -fsyntax-only -verify void test() { char = 4; // expected-error {{expected identifier}} expected-error{{declarator requires an identifier}} Modified: cfe/trunk/test/Sema/method-def-1.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/method-def-1.m?rev=44918&r1=44917&r2=44918&view=diff ============================================================================== --- cfe/trunk/test/Sema/method-def-1.m (original) +++ cfe/trunk/test/Sema/method-def-1.m Wed Dec 12 00:22:14 2007 @@ -1,3 +1,5 @@ +// RUN: clang -fsyntax-only %s + @interface foo - (int)meth; @end From sabre at nondot.org Wed Dec 12 00:43:06 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 06:43:06 -0000 Subject: [cfe-commits] r44919 - in /cfe/trunk: AST/ASTContext.cpp test/Sema/carbon.c test/Sema/cocoa.m Message-ID: <200712120643.lBC6h6Ik011812@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 00:43:05 2007 New Revision: 44919 URL: http://llvm.org/viewvc/llvm-project?rev=44919&view=rev Log: Unbreak -stats on cocoa.h Modified: cfe/trunk/AST/ASTContext.cpp cfe/trunk/test/Sema/carbon.c cfe/trunk/test/Sema/cocoa.m Modified: cfe/trunk/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=44919&r1=44918&r2=44919&view=diff ============================================================================== --- cfe/trunk/AST/ASTContext.cpp (original) +++ cfe/trunk/AST/ASTContext.cpp Wed Dec 12 00:43:05 2007 @@ -48,7 +48,7 @@ unsigned NumFunctionNP = 0, NumTypeName = 0, NumTagged = 0, NumReference = 0; unsigned NumTagStruct = 0, NumTagUnion = 0, NumTagEnum = 0, NumTagClass = 0; - unsigned NumObjcInterfaces = 0; + unsigned NumObjcInterfaces = 0, NumObjcQualifiedInterfaces = 0; for (unsigned i = 0, e = Types.size(); i != e; ++i) { Type *T = Types[i]; @@ -81,7 +81,10 @@ } } else if (isa(T)) ++NumObjcInterfaces; + else if (isa(T)) + ++NumObjcQualifiedInterfaces; else { + QualType(T, 0).dump(); assert(0 && "Unknown type!"); } } @@ -101,6 +104,8 @@ fprintf(stderr, " %d class types\n", NumTagClass); fprintf(stderr, " %d enum types\n", NumTagEnum); fprintf(stderr, " %d interface types\n", NumObjcInterfaces); + fprintf(stderr, " %d protocol qualified interface types\n", + NumObjcQualifiedInterfaces); fprintf(stderr, "Total bytes = %d\n", int(NumBuiltin*sizeof(BuiltinType)+ NumPointer*sizeof(PointerType)+NumArray*sizeof(ArrayType)+ NumComplex*sizeof(ComplexType)+NumVector*sizeof(VectorType)+ Modified: cfe/trunk/test/Sema/carbon.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/carbon.c?rev=44919&r1=44918&r2=44919&view=diff ============================================================================== --- cfe/trunk/test/Sema/carbon.c (original) +++ cfe/trunk/test/Sema/carbon.c Wed Dec 12 00:43:05 2007 @@ -1,4 +1,4 @@ -// RUN: clang %s -fsyntax-only +// RUN: clang %s -fsyntax-only -stats #ifdef __APPLE__ #include #endif Modified: cfe/trunk/test/Sema/cocoa.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/cocoa.m?rev=44919&r1=44918&r2=44919&view=diff ============================================================================== --- cfe/trunk/test/Sema/cocoa.m (original) +++ cfe/trunk/test/Sema/cocoa.m Wed Dec 12 00:43:05 2007 @@ -1,4 +1,4 @@ -// RUN: clang %s +// RUN: clang %s -stats #ifdef __APPLE__ #include #endif From kremenek at apple.com Wed Dec 12 00:44:13 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 06:44:13 -0000 Subject: [cfe-commits] r44920 - /cfe/trunk/AST/StmtDumper.cpp Message-ID: <200712120644.lBC6iEP1011984@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 00:44:12 2007 New Revision: 44920 URL: http://llvm.org/viewvc/llvm-project?rev=44920&view=rev Log: Removed VisitDeclStmt(). The initializers of a DeclStmt are now automatically printed out by DumpSubTree() via the child_iterator interface. This fixes a bug where the initializers were being dumped twice. Modified: cfe/trunk/AST/StmtDumper.cpp Modified: cfe/trunk/AST/StmtDumper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtDumper.cpp?rev=44920&r1=44919&r2=44920&view=diff ============================================================================== --- cfe/trunk/AST/StmtDumper.cpp (original) +++ cfe/trunk/AST/StmtDumper.cpp Wed Dec 12 00:44:12 2007 @@ -102,7 +102,6 @@ // Stmts. void VisitStmt(Stmt *Node); - void VisitDeclStmt(DeclStmt *Node); void VisitLabelStmt(LabelStmt *Node); void VisitGotoStmt(GotoStmt *Node); @@ -233,20 +232,6 @@ } } -void StmtDumper::VisitDeclStmt(DeclStmt *Node) { - DumpStmt(Node); - fprintf(F, "\n"); - for (ScopedDecl *D = Node->getDecl(); D; D = D->getNextDeclarator()) { - ++IndentLevel; - Indent(); - fprintf(F, "%p ", (void*)D); - DumpDeclarator(D); - if (D->getNextDeclarator()) - fprintf(F, "\n"); - --IndentLevel; - } -} - void StmtDumper::VisitLabelStmt(LabelStmt *Node) { DumpStmt(Node); fprintf(F, " '%s'\n", Node->getName()); From sabre at nondot.org Wed Dec 12 00:54:27 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 06:54:27 -0000 Subject: [cfe-commits] r44922 - /cfe/trunk/Parse/ParseStmt.cpp Message-ID: <200712120654.lBC6sRjx012590@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 00:54:22 2007 New Revision: 44922 URL: http://llvm.org/viewvc/llvm-project?rev=44922&view=rev Log: remove todo Modified: cfe/trunk/Parse/ParseStmt.cpp Modified: cfe/trunk/Parse/ParseStmt.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=44922&r1=44921&r2=44922&view=diff ============================================================================== --- cfe/trunk/Parse/ParseStmt.cpp (original) +++ cfe/trunk/Parse/ParseStmt.cpp Wed Dec 12 00:54:22 2007 @@ -1075,6 +1075,5 @@ // Leave the function body scope. ExitScope(); - // TODO: Pass argument information. return Actions.ActOnFinishFunctionBody(Decl, FnBody.Val); } From sabre at nondot.org Wed Dec 12 00:56:33 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 06:56:33 -0000 Subject: [cfe-commits] r44923 - in /cfe/trunk/Parse: ParseDecl.cpp ParseObjc.cpp Message-ID: <200712120656.lBC6uXEn012674@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 00:56:32 2007 New Revision: 44923 URL: http://llvm.org/viewvc/llvm-project?rev=44923&view=rev Log: move function to a more logical location, add its grammar productions. Modified: cfe/trunk/Parse/ParseDecl.cpp cfe/trunk/Parse/ParseObjc.cpp Modified: cfe/trunk/Parse/ParseDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseDecl.cpp?rev=44923&r1=44922&r2=44923&view=diff ============================================================================== --- cfe/trunk/Parse/ParseDecl.cpp (original) +++ cfe/trunk/Parse/ParseDecl.cpp Wed Dec 12 00:56:32 2007 @@ -552,40 +552,6 @@ } } -/// ParseObjcTypeQualifierList - This routine parses the objective-c's type -/// qualifier list and builds their bitmask representation in the input -/// argument. -void Parser::ParseObjcTypeQualifierList(ObjcDeclSpec &DS) { - while (1) { - if (!Tok.is(tok::identifier)) - return; - - const IdentifierInfo *II = Tok.getIdentifierInfo(); - for (unsigned i = 0; i != objc_NumQuals; ++i) { - if (II != ObjcTypeQuals[i]) - continue; - - ObjcDeclSpec::ObjcDeclQualifier Qual; - switch (i) { - default: assert(0 && "Unknown decl qualifier"); - case objc_in: Qual = ObjcDeclSpec::DQ_In; break; - case objc_out: Qual = ObjcDeclSpec::DQ_Out; break; - case objc_inout: Qual = ObjcDeclSpec::DQ_Inout; break; - case objc_oneway: Qual = ObjcDeclSpec::DQ_Oneway; break; - case objc_bycopy: Qual = ObjcDeclSpec::DQ_Bycopy; break; - case objc_byref: Qual = ObjcDeclSpec::DQ_Byref; break; - } - DS.setObjcDeclQualifier(Qual); - ConsumeToken(); - II = 0; - break; - } - - // If this wasn't a recognized qualifier, bail out. - if (II) return; - } -} - /// ParseTag - Parse "struct-or-union-or-class-or-enum identifier[opt]", where /// the first token has already been read and has been turned into an instance /// of DeclSpec::TST (TagType). This returns true if there is an error parsing, Modified: cfe/trunk/Parse/ParseObjc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=44923&r1=44922&r2=44923&view=diff ============================================================================== --- cfe/trunk/Parse/ParseObjc.cpp (original) +++ cfe/trunk/Parse/ParseObjc.cpp Wed Dec 12 00:56:32 2007 @@ -491,14 +491,49 @@ return false; } -/// objc-type-name: -/// '(' objc-type-qualifiers[opt] type-name ')' -/// '(' objc-type-qualifiers[opt] ')' +/// ParseObjcTypeQualifierList - This routine parses the objective-c's type +/// qualifier list and builds their bitmask representation in the input +/// argument. /// /// objc-type-qualifiers: /// objc-type-qualifier /// objc-type-qualifiers objc-type-qualifier /// +void Parser::ParseObjcTypeQualifierList(ObjcDeclSpec &DS) { + while (1) { + if (!Tok.is(tok::identifier)) + return; + + const IdentifierInfo *II = Tok.getIdentifierInfo(); + for (unsigned i = 0; i != objc_NumQuals; ++i) { + if (II != ObjcTypeQuals[i]) + continue; + + ObjcDeclSpec::ObjcDeclQualifier Qual; + switch (i) { + default: assert(0 && "Unknown decl qualifier"); + case objc_in: Qual = ObjcDeclSpec::DQ_In; break; + case objc_out: Qual = ObjcDeclSpec::DQ_Out; break; + case objc_inout: Qual = ObjcDeclSpec::DQ_Inout; break; + case objc_oneway: Qual = ObjcDeclSpec::DQ_Oneway; break; + case objc_bycopy: Qual = ObjcDeclSpec::DQ_Bycopy; break; + case objc_byref: Qual = ObjcDeclSpec::DQ_Byref; break; + } + DS.setObjcDeclQualifier(Qual); + ConsumeToken(); + II = 0; + break; + } + + // If this wasn't a recognized qualifier, bail out. + if (II) return; + } +} + +/// objc-type-name: +/// '(' objc-type-qualifiers[opt] type-name ')' +/// '(' objc-type-qualifiers[opt] ')' +/// Parser::TypeTy *Parser::ParseObjCTypeName(ObjcDeclSpec &DS) { assert(Tok.is(tok::l_paren) && "expected ("); From kremenek at apple.com Wed Dec 12 00:59:42 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 06:59:42 -0000 Subject: [cfe-commits] r44924 - /cfe/trunk/AST/StmtDumper.cpp Message-ID: <200712120659.lBC6xgZH012818@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 00:59:42 2007 New Revision: 44924 URL: http://llvm.org/viewvc/llvm-project?rev=44924&view=rev Log: Added back VisitDeclStmt() to the StmtDumper, essentially reverting r44920: http://llvm.org/viewvc/llvm-project?rev=44920&view=rev Putting VisitDeclStmt() was motivated because it called DumpDeclarator(), which printed out a little bit more information than just using the child_iterator interface to visit the subexpressions of DeclStmt. To avoid printing the initializers twice, DumpSubTree() now specially checks for DeclStmts; in such cases it calls VisitDeclStmt() without using the child_iterators to visit the subexpressions. Modified: cfe/trunk/AST/StmtDumper.cpp Modified: cfe/trunk/AST/StmtDumper.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtDumper.cpp?rev=44924&r1=44923&r2=44924&view=diff ============================================================================== --- cfe/trunk/AST/StmtDumper.cpp (original) +++ cfe/trunk/AST/StmtDumper.cpp Wed Dec 12 00:59:42 2007 @@ -54,17 +54,21 @@ ++IndentLevel; if (S) { - Visit(S); - - // Print out children. - Stmt::child_iterator CI = S->child_begin(), CE = S->child_end(); - if (CI != CE) { - while (CI != CE) { - fprintf(F, "\n"); - DumpSubTree(*CI++); + if (DeclStmt* DS = dyn_cast(S)) + VisitDeclStmt(DS); + else { + Visit(S); + + // Print out children. + Stmt::child_iterator CI = S->child_begin(), CE = S->child_end(); + if (CI != CE) { + while (CI != CE) { + fprintf(F, "\n"); + DumpSubTree(*CI++); + } } + fprintf(F, ")"); } - fprintf(F, ")"); } else { Indent(); fprintf(F, "<<>>"); @@ -102,6 +106,7 @@ // Stmts. void VisitStmt(Stmt *Node); + void VisitDeclStmt(DeclStmt *Node); void VisitLabelStmt(LabelStmt *Node); void VisitGotoStmt(GotoStmt *Node); @@ -232,6 +237,20 @@ } } +void StmtDumper::VisitDeclStmt(DeclStmt *Node) { + DumpStmt(Node); + fprintf(F,"\n"); + for (ScopedDecl *D = Node->getDecl(); D; D = D->getNextDeclarator()) { + ++IndentLevel; + Indent(); + fprintf(F, "%p ", (void*) D); + DumpDeclarator(D); + if (D->getNextDeclarator()) + fprintf(F,"\n"); + --IndentLevel; + } +} + void StmtDumper::VisitLabelStmt(LabelStmt *Node) { DumpStmt(Node); fprintf(F, " '%s'\n", Node->getName()); From sabre at nondot.org Wed Dec 12 01:09:47 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 07:09:47 -0000 Subject: [cfe-commits] r44925 - in /cfe/trunk: Sema/SemaDecl.cpp Sema/SemaDeclObjC.cpp clang.xcodeproj/project.pbxproj Message-ID: <200712120709.lBC79lKm013823@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 01:09:47 2007 New Revision: 44925 URL: http://llvm.org/viewvc/llvm-project?rev=44925&view=rev Log: split objc pieces of SemaDecl.cpp out into SemaDeclObjC.cpp Added: cfe/trunk/Sema/SemaDeclObjC.cpp Modified: cfe/trunk/Sema/SemaDecl.cpp cfe/trunk/clang.xcodeproj/project.pbxproj Modified: cfe/trunk/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=44925&r1=44924&r2=44925&view=diff ============================================================================== --- cfe/trunk/Sema/SemaDecl.cpp (original) +++ cfe/trunk/Sema/SemaDecl.cpp Wed Dec 12 01:09:47 2007 @@ -15,7 +15,6 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/Builtins.h" #include "clang/AST/Decl.h" -#include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" #include "clang/AST/Type.h" #include "clang/Parse/DeclSpec.h" @@ -25,7 +24,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/DenseSet.h" -#include "clang/Lex/Preprocessor.h" using namespace clang; Sema::DeclTy *Sema::isTypeName(const IdentifierInfo &II, Scope *S) const { @@ -210,7 +208,7 @@ // Allow multiple definitions for ObjC built-in typedefs. // FIXME: Verify the underlying types are equivalent! - if (PP.getLangOptions().ObjC1 && isBuiltinObjcType(New)) + if (getLangOptions().ObjC1 && isBuiltinObjcType(New)) return Old; // TODO: CHECK FOR CONFLICTS, multiple decls with same name in one scope. @@ -1050,45 +1048,6 @@ return D; } -/// ObjcActOnStartOfMethodDef - This routine sets up parameters; invisible -/// and user declared, in the method definition's AST. -void Sema::ObjcActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { - assert(CurFunctionDecl == 0 && "Method parsing confused"); - ObjcMethodDecl *MDecl = dyn_cast(static_cast(D)); - assert(MDecl != 0 && "Not a method declarator!"); - - // Allow all of Sema to see that we are entering a method definition. - CurMethodDecl = MDecl; - - // Create Decl objects for each parameter, entrring them in the scope for - // binding to their use. - struct DeclaratorChunk::ParamInfo PI; - - // Insert the invisible arguments, self and _cmd! - PI.Ident = &Context.Idents.get("self"); - PI.IdentLoc = SourceLocation(); // synthesized vars have a null location. - PI.InvalidType = false; - if (MDecl->isInstance()) { - QualType selfTy = Context.getObjcInterfaceType(MDecl->getClassInterface()); - selfTy = Context.getPointerType(selfTy); - PI.TypeInfo = selfTy.getAsOpaquePtr(); - } else - PI.TypeInfo = Context.getObjcIdType().getAsOpaquePtr(); - CurMethodDecl->setSelfDecl(ActOnParamDeclarator(PI, FnBodyScope)); - - PI.Ident = &Context.Idents.get("_cmd"); - PI.TypeInfo = Context.getObjcSelType().getAsOpaquePtr(); - ActOnParamDeclarator(PI, FnBodyScope); - - for (int i = 0; i < MDecl->getNumParams(); i++) { - ParmVarDecl *PDecl = MDecl->getParamDecl(i); - PI.Ident = PDecl->getIdentifier(); - PI.IdentLoc = PDecl->getLocation(); // user vars have a real location. - PI.TypeInfo = PDecl->getType().getAsOpaquePtr(); - ActOnParamDeclarator(PI, FnBodyScope); - } -} - /// ImplicitlyDefineFunction - An undeclared identifier was used in a function /// call, forming a call to an implicitly defined function (per C99 6.5.1p2). ScopedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, @@ -1135,550 +1094,6 @@ return NewTD; } -Sema::DeclTy *Sema::ActOnStartClassInterface( - SourceLocation AtInterfaceLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *SuperName, SourceLocation SuperLoc, - IdentifierInfo **ProtocolNames, unsigned NumProtocols, - SourceLocation EndProtoLoc, AttributeList *AttrList) { - assert(ClassName && "Missing class identifier"); - - // Check for another declaration kind with the same name. - ScopedDecl *PrevDecl = LookupInterfaceDecl(ClassName); - if (PrevDecl && !isa(PrevDecl)) { - Diag(ClassLoc, diag::err_redefinition_different_kind, - ClassName->getName()); - Diag(PrevDecl->getLocation(), diag::err_previous_definition); - } - - ObjcInterfaceDecl* IDecl = dyn_cast_or_null(PrevDecl); - if (IDecl) { - // Class already seen. Is it a forward declaration? - if (!IDecl->isForwardDecl()) - Diag(AtInterfaceLoc, diag::err_duplicate_class_def, IDecl->getName()); - else { - IDecl->setLocation(AtInterfaceLoc); - IDecl->setForwardDecl(false); - IDecl->AllocIntfRefProtocols(NumProtocols); - } - } - else { - IDecl = new ObjcInterfaceDecl(AtInterfaceLoc, NumProtocols, ClassName); - - // Chain & install the interface decl into the identifier. - IDecl->setNext(ClassName->getFETokenInfo()); - ClassName->setFETokenInfo(IDecl); - - // Remember that this needs to be removed when the scope is popped. - TUScope->AddDecl(IDecl); - } - - if (SuperName) { - ObjcInterfaceDecl* SuperClassEntry = 0; - // Check if a different kind of symbol declared in this scope. - PrevDecl = LookupInterfaceDecl(SuperName); - if (PrevDecl && !isa(PrevDecl)) { - Diag(SuperLoc, diag::err_redefinition_different_kind, - SuperName->getName()); - Diag(PrevDecl->getLocation(), diag::err_previous_definition); - } - else { - // Check that super class is previously defined - SuperClassEntry = dyn_cast_or_null(PrevDecl); - - if (!SuperClassEntry || SuperClassEntry->isForwardDecl()) { - Diag(AtInterfaceLoc, diag::err_undef_superclass, - SuperClassEntry ? SuperClassEntry->getName() - : SuperName->getName(), - ClassName->getName()); - } - } - IDecl->setSuperClass(SuperClassEntry); - IDecl->setLocEnd(SuperLoc); - } else { // we have a root class. - IDecl->setLocEnd(ClassLoc); - } - - /// Check then save referenced protocols - if (NumProtocols) { - for (unsigned int i = 0; i != NumProtocols; i++) { - ObjcProtocolDecl* RefPDecl = ObjcProtocols[ProtocolNames[i]]; - if (!RefPDecl || RefPDecl->isForwardDecl()) - Diag(ClassLoc, diag::warn_undef_protocolref, - ProtocolNames[i]->getName(), - ClassName->getName()); - IDecl->setIntfRefProtocols((int)i, RefPDecl); - } - IDecl->setLocEnd(EndProtoLoc); - } - return IDecl; -} - -/// ActOnCompatiblityAlias - this action is called after complete parsing of -/// @compaatibility_alias declaration. It sets up the alias relationships. -Sema::DeclTy *Sema::ActOnCompatiblityAlias( - SourceLocation AtCompatibilityAliasLoc, - IdentifierInfo *AliasName, SourceLocation AliasLocation, - IdentifierInfo *ClassName, SourceLocation ClassLocation) { - // Look for previous declaration of alias name - ScopedDecl *ADecl = LookupScopedDecl(AliasName, Decl::IDNS_Ordinary, - AliasLocation, TUScope); - if (ADecl) { - if (isa(ADecl)) { - Diag(AliasLocation, diag::warn_previous_alias_decl); - Diag(ADecl->getLocation(), diag::warn_previous_declaration); - } - else { - Diag(AliasLocation, diag::err_conflicting_aliasing_type, - AliasName->getName()); - Diag(ADecl->getLocation(), diag::err_previous_declaration); - } - return 0; - } - // Check for class declaration - ScopedDecl *CDecl = LookupScopedDecl(ClassName, Decl::IDNS_Ordinary, - ClassLocation, TUScope); - if (!CDecl || !isa(CDecl)) { - Diag(ClassLocation, diag::warn_undef_interface, - ClassName->getName()); - if (CDecl) - Diag(CDecl->getLocation(), diag::warn_previous_declaration); - return 0; - } - // Everything checked out, instantiate a new alias declaration ast - ObjcCompatibleAliasDecl *AliasDecl = - new ObjcCompatibleAliasDecl(AtCompatibilityAliasLoc, - AliasName, - dyn_cast(CDecl)); - - // Chain & install the interface decl into the identifier. - AliasDecl->setNext(AliasName->getFETokenInfo()); - AliasName->setFETokenInfo(AliasDecl); - return AliasDecl; -} - -Sema::DeclTy *Sema::ActOnStartProtocolInterface( - SourceLocation AtProtoInterfaceLoc, - IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, - IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs, - SourceLocation EndProtoLoc) { - assert(ProtocolName && "Missing protocol identifier"); - ObjcProtocolDecl *PDecl = ObjcProtocols[ProtocolName]; - if (PDecl) { - // Protocol already seen. Better be a forward protocol declaration - if (!PDecl->isForwardDecl()) - Diag(ProtocolLoc, diag::err_duplicate_protocol_def, - ProtocolName->getName()); - else { - PDecl->setForwardDecl(false); - PDecl->AllocReferencedProtocols(NumProtoRefs); - } - } - else { - PDecl = new ObjcProtocolDecl(AtProtoInterfaceLoc, NumProtoRefs, - ProtocolName); - ObjcProtocols[ProtocolName] = PDecl; - } - - if (NumProtoRefs) { - /// Check then save referenced protocols - for (unsigned int i = 0; i != NumProtoRefs; i++) { - ObjcProtocolDecl* RefPDecl = ObjcProtocols[ProtoRefNames[i]]; - if (!RefPDecl || RefPDecl->isForwardDecl()) - Diag(ProtocolLoc, diag::warn_undef_protocolref, - ProtoRefNames[i]->getName(), - ProtocolName->getName()); - PDecl->setReferencedProtocols((int)i, RefPDecl); - } - PDecl->setLocEnd(EndProtoLoc); - } - return PDecl; -} - -/// FindProtocolDeclaration - This routine looks up protocols and -/// issuer error if they are not declared. It returns list of protocol -/// declarations in its 'Protocols' argument. -void -Sema::FindProtocolDeclaration(SourceLocation TypeLoc, - IdentifierInfo **ProtocolId, - unsigned NumProtocols, - llvm::SmallVector &Protocols) { - for (unsigned i = 0; i != NumProtocols; ++i) { - ObjcProtocolDecl *PDecl = ObjcProtocols[ProtocolId[i]]; - if (!PDecl) - Diag(TypeLoc, diag::err_undeclared_protocol, - ProtocolId[i]->getName()); - else - Protocols.push_back(PDecl); - } -} - -/// ActOnForwardProtocolDeclaration - -Action::DeclTy * -Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, - IdentifierInfo **IdentList, unsigned NumElts) { - llvm::SmallVector Protocols; - - for (unsigned i = 0; i != NumElts; ++i) { - IdentifierInfo *P = IdentList[i]; - ObjcProtocolDecl *PDecl = ObjcProtocols[P]; - if (!PDecl) { // Not already seen? - // FIXME: Pass in the location of the identifier! - PDecl = new ObjcProtocolDecl(AtProtocolLoc, 0, P, true); - ObjcProtocols[P] = PDecl; - } - - Protocols.push_back(PDecl); - } - return new ObjcForwardProtocolDecl(AtProtocolLoc, - &Protocols[0], Protocols.size()); -} - -Sema::DeclTy *Sema::ActOnStartCategoryInterface( - SourceLocation AtInterfaceLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *CategoryName, SourceLocation CategoryLoc, - IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs, - SourceLocation EndProtoLoc) { - ObjcInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); - - /// Check that class of this category is already completely declared. - if (!IDecl || IDecl->isForwardDecl()) { - Diag(ClassLoc, diag::err_undef_interface, ClassName->getName()); - return 0; - } - ObjcCategoryDecl *CDecl = new ObjcCategoryDecl(AtInterfaceLoc, NumProtoRefs, - CategoryName); - CDecl->setClassInterface(IDecl); - /// Check for duplicate interface declaration for this category - ObjcCategoryDecl *CDeclChain; - for (CDeclChain = IDecl->getCategoryList(); CDeclChain; - CDeclChain = CDeclChain->getNextClassCategory()) { - if (CDeclChain->getIdentifier() == CategoryName) { - Diag(CategoryLoc, diag::err_dup_category_def, ClassName->getName(), - CategoryName->getName()); - break; - } - } - if (!CDeclChain) - CDecl->insertNextClassCategory(); - - if (NumProtoRefs) { - /// Check then save referenced protocols - for (unsigned int i = 0; i != NumProtoRefs; i++) { - ObjcProtocolDecl* RefPDecl = ObjcProtocols[ProtoRefNames[i]]; - if (!RefPDecl || RefPDecl->isForwardDecl()) { - Diag(CategoryLoc, diag::warn_undef_protocolref, - ProtoRefNames[i]->getName(), - CategoryName->getName()); - } - CDecl->setCatReferencedProtocols((int)i, RefPDecl); - } - CDecl->setLocEnd(EndProtoLoc); - } - return CDecl; -} - -/// ActOnStartCategoryImplementation - Perform semantic checks on the -/// category implementation declaration and build an ObjcCategoryImplDecl -/// object. -Sema::DeclTy *Sema::ActOnStartCategoryImplementation( - SourceLocation AtCatImplLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *CatName, SourceLocation CatLoc) { - ObjcInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); - ObjcCategoryImplDecl *CDecl = new ObjcCategoryImplDecl(AtCatImplLoc, - CatName, IDecl); - /// Check that class of this category is already completely declared. - if (!IDecl || IDecl->isForwardDecl()) - Diag(ClassLoc, diag::err_undef_interface, ClassName->getName()); - - /// TODO: Check that CatName, category name, is not used in another - // implementation. - return CDecl; -} - -Sema::DeclTy *Sema::ActOnStartClassImplementation( - SourceLocation AtClassImplLoc, - IdentifierInfo *ClassName, SourceLocation ClassLoc, - IdentifierInfo *SuperClassname, - SourceLocation SuperClassLoc) { - ObjcInterfaceDecl* IDecl = 0; - // Check for another declaration kind with the same name. - ScopedDecl *PrevDecl = LookupInterfaceDecl(ClassName); - if (PrevDecl && !isa(PrevDecl)) { - Diag(ClassLoc, diag::err_redefinition_different_kind, - ClassName->getName()); - Diag(PrevDecl->getLocation(), diag::err_previous_definition); - } - else { - // Is there an interface declaration of this class; if not, warn! - IDecl = dyn_cast_or_null(PrevDecl); - if (!IDecl) - Diag(ClassLoc, diag::warn_undef_interface, ClassName->getName()); - } - - // Check that super class name is valid class name - ObjcInterfaceDecl* SDecl = 0; - if (SuperClassname) { - // Check if a different kind of symbol declared in this scope. - PrevDecl = LookupInterfaceDecl(SuperClassname); - if (PrevDecl && !isa(PrevDecl)) { - Diag(SuperClassLoc, diag::err_redefinition_different_kind, - SuperClassname->getName()); - Diag(PrevDecl->getLocation(), diag::err_previous_definition); - } - else { - SDecl = dyn_cast_or_null(PrevDecl); - if (!SDecl) - Diag(SuperClassLoc, diag::err_undef_superclass, - SuperClassname->getName(), ClassName->getName()); - else if (IDecl && IDecl->getSuperClass() != SDecl) { - // This implementation and its interface do not have the same - // super class. - Diag(SuperClassLoc, diag::err_conflicting_super_class, - SDecl->getName()); - Diag(SDecl->getLocation(), diag::err_previous_definition); - } - } - } - - if (!IDecl) { - // Legacy case of @implementation with no corresponding @interface. - // Build, chain & install the interface decl into the identifier. - IDecl = new ObjcInterfaceDecl(AtClassImplLoc, 0, ClassName, - false, true); - IDecl->setNext(ClassName->getFETokenInfo()); - ClassName->setFETokenInfo(IDecl); - IDecl->setSuperClass(SDecl); - IDecl->setLocEnd(ClassLoc); - - // Remember that this needs to be removed when the scope is popped. - TUScope->AddDecl(IDecl); - } - - ObjcImplementationDecl* IMPDecl = - new ObjcImplementationDecl(AtClassImplLoc, ClassName, IDecl, SDecl); - - // Check that there is no duplicate implementation of this class. - if (ObjcImplementations[ClassName]) - Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName()); - else // add it to the list. - ObjcImplementations[ClassName] = IMPDecl; - return IMPDecl; -} - -void Sema::CheckImplementationIvars(ObjcImplementationDecl *ImpDecl, - ObjcIvarDecl **ivars, unsigned numIvars, - SourceLocation RBrace) { - assert(ImpDecl && "missing implementation decl"); - ObjcInterfaceDecl* IDecl = getObjCInterfaceDecl(ImpDecl->getIdentifier()); - if (!IDecl) - return; - /// Check case of non-existing @interface decl. - /// (legacy objective-c @implementation decl without an @interface decl). - /// Add implementations's ivar to the synthesize class's ivar list. - if (IDecl->ImplicitInterfaceDecl()) { - IDecl->addInstanceVariablesToClass(ivars, numIvars, RBrace); - return; - } - // If implementation has empty ivar list, just return. - if (numIvars == 0) - return; - - assert(ivars && "missing @implementation ivars"); - - // Check interface's Ivar list against those in the implementation. - // names and types must match. - // - ObjcIvarDecl** IntfIvars = IDecl->getInstanceVariables(); - int IntfNumIvars = IDecl->getNumInstanceVariables(); - unsigned j = 0; - bool err = false; - while (numIvars > 0 && IntfNumIvars > 0) { - ObjcIvarDecl* ImplIvar = ivars[j]; - ObjcIvarDecl* ClsIvar = IntfIvars[j++]; - assert (ImplIvar && "missing implementation ivar"); - assert (ClsIvar && "missing class ivar"); - if (ImplIvar->getCanonicalType() != ClsIvar->getCanonicalType()) { - Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_type, - ImplIvar->getIdentifier()->getName()); - Diag(ClsIvar->getLocation(), diag::err_previous_definition, - ClsIvar->getIdentifier()->getName()); - } - // TODO: Two mismatched (unequal width) Ivar bitfields should be diagnosed - // as error. - else if (ImplIvar->getIdentifier() != ClsIvar->getIdentifier()) { - Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_name, - ImplIvar->getIdentifier()->getName()); - Diag(ClsIvar->getLocation(), diag::err_previous_definition, - ClsIvar->getIdentifier()->getName()); - err = true; - break; - } - --numIvars; - --IntfNumIvars; - } - if (!err && (numIvars > 0 || IntfNumIvars > 0)) - Diag(numIvars > 0 ? ivars[j]->getLocation() : IntfIvars[j]->getLocation(), - diag::err_inconsistant_ivar); - -} - -/// CheckProtocolMethodDefs - This routine checks unimpletented methods -/// Declared in protocol, and those referenced by it. -void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl, - bool& IncompleteImpl, - const llvm::DenseSet &InsMap, - const llvm::DenseSet &ClsMap) { - // check unimplemented instance methods. - ObjcMethodDecl** methods = PDecl->getInstanceMethods(); - for (int j = 0; j < PDecl->getNumInstanceMethods(); j++) { - if (!InsMap.count(methods[j]->getSelector()) && - methods[j]->getImplementationControl() != ObjcMethodDecl::Optional) { - Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, - methods[j]->getSelector().getName()); - IncompleteImpl = true; - } - } - // check unimplemented class methods - methods = PDecl->getClassMethods(); - for (int j = 0; j < PDecl->getNumClassMethods(); j++) - if (!ClsMap.count(methods[j]->getSelector()) && - methods[j]->getImplementationControl() != ObjcMethodDecl::Optional) { - Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, - methods[j]->getSelector().getName()); - IncompleteImpl = true; - } - - // Check on this protocols's referenced protocols, recursively - ObjcProtocolDecl** RefPDecl = PDecl->getReferencedProtocols(); - for (int i = 0; i < PDecl->getNumReferencedProtocols(); i++) - CheckProtocolMethodDefs(RefPDecl[i], IncompleteImpl, InsMap, ClsMap); -} - -void Sema::ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl, - ObjcInterfaceDecl* IDecl) { - llvm::DenseSet InsMap; - // Check and see if instance methods in class interface have been - // implemented in the implementation class. - ObjcMethodDecl *const*methods = IMPDecl->getInstanceMethods(); - for (int i=0; i < IMPDecl->getNumInstanceMethods(); i++) - InsMap.insert(methods[i]->getSelector()); - - bool IncompleteImpl = false; - methods = IDecl->getInstanceMethods(); - for (int j = 0; j < IDecl->getNumInstanceMethods(); j++) - if (!InsMap.count(methods[j]->getSelector())) { - Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, - methods[j]->getSelector().getName()); - IncompleteImpl = true; - } - llvm::DenseSet ClsMap; - // Check and see if class methods in class interface have been - // implemented in the implementation class. - methods = IMPDecl->getClassMethods(); - for (int i=0; i < IMPDecl->getNumClassMethods(); i++) - ClsMap.insert(methods[i]->getSelector()); - - methods = IDecl->getClassMethods(); - for (int j = 0; j < IDecl->getNumClassMethods(); j++) - if (!ClsMap.count(methods[j]->getSelector())) { - Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, - methods[j]->getSelector().getName()); - IncompleteImpl = true; - } - - // Check the protocol list for unimplemented methods in the @implementation - // class. - ObjcProtocolDecl** protocols = IDecl->getReferencedProtocols(); - for (int i = 0; i < IDecl->getNumIntfRefProtocols(); i++) - CheckProtocolMethodDefs(protocols[i], IncompleteImpl, InsMap, ClsMap); - - if (IncompleteImpl) - Diag(IMPDecl->getLocation(), diag::warn_incomplete_impl_class, - IMPDecl->getName()); -} - -/// ImplCategoryMethodsVsIntfMethods - Checks that methods declared in the -/// category interface is implemented in the category @implementation. -void Sema::ImplCategoryMethodsVsIntfMethods(ObjcCategoryImplDecl *CatImplDecl, - ObjcCategoryDecl *CatClassDecl) { - llvm::DenseSet InsMap; - // Check and see if instance methods in category interface have been - // implemented in its implementation class. - ObjcMethodDecl *const*methods = CatImplDecl->getInstanceMethods(); - for (int i=0; i < CatImplDecl->getNumInstanceMethods(); i++) - InsMap.insert(methods[i]->getSelector()); - - bool IncompleteImpl = false; - methods = CatClassDecl->getInstanceMethods(); - for (int j = 0; j < CatClassDecl->getNumInstanceMethods(); j++) - if (!InsMap.count(methods[j]->getSelector())) { - Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, - methods[j]->getSelector().getName()); - IncompleteImpl = true; - } - llvm::DenseSet ClsMap; - // Check and see if class methods in category interface have been - // implemented in its implementation class. - methods = CatImplDecl->getClassMethods(); - for (int i=0; i < CatImplDecl->getNumClassMethods(); i++) - ClsMap.insert(methods[i]->getSelector()); - - methods = CatClassDecl->getClassMethods(); - for (int j = 0; j < CatClassDecl->getNumClassMethods(); j++) - if (!ClsMap.count(methods[j]->getSelector())) { - Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, - methods[j]->getSelector().getName()); - IncompleteImpl = true; - } - - // Check the protocol list for unimplemented methods in the @implementation - // class. - ObjcProtocolDecl** protocols = CatClassDecl->getReferencedProtocols(); - for (int i = 0; i < CatClassDecl->getNumReferencedProtocols(); i++) { - ObjcProtocolDecl* PDecl = protocols[i]; - CheckProtocolMethodDefs(PDecl, IncompleteImpl, InsMap, ClsMap); - } - if (IncompleteImpl) - Diag(CatImplDecl->getLocation(), diag::warn_incomplete_impl_category, - CatClassDecl->getName()); -} - -/// ActOnForwardClassDeclaration - -Action::DeclTy * -Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, - IdentifierInfo **IdentList, unsigned NumElts) -{ - llvm::SmallVector Interfaces; - - for (unsigned i = 0; i != NumElts; ++i) { - // Check for another declaration kind with the same name. - ScopedDecl *PrevDecl = LookupInterfaceDecl(IdentList[i]); - if (PrevDecl && !isa(PrevDecl)) { - Diag(AtClassLoc, diag::err_redefinition_different_kind, - IdentList[i]->getName()); - Diag(PrevDecl->getLocation(), diag::err_previous_definition); - } - ObjcInterfaceDecl *IDecl = dyn_cast_or_null(PrevDecl); - if (!IDecl) { // Not already seen? Make a forward decl. - IDecl = new ObjcInterfaceDecl(AtClassLoc, 0, IdentList[i], true); - // Chain & install the interface decl into the identifier. - IDecl->setNext(IdentList[i]->getFETokenInfo()); - IdentList[i]->setFETokenInfo(IDecl); - - // Remember that this needs to be removed when the scope is popped. - TUScope->AddDecl(IDecl); - } - - Interfaces.push_back(IDecl); - } - - return new ObjcClassDecl(AtClassLoc, &Interfaces[0], Interfaces.size()); -} - - /// ActOnTag - This is invoked when we see 'struct foo' or 'struct {'. In the /// former case, Name will be non-null. In the later case, Name will be null. /// TagType indicates what kind of tag this is. TK indicates whether this is a @@ -2007,316 +1422,6 @@ } } -/// MatchTwoMethodDeclarations - Checks that two methods have matching type and -/// returns true, or false, accordingly. -/// TODO: Handle protocol list; such as id in type comparisons -bool Sema:: MatchTwoMethodDeclarations(const ObjcMethodDecl *Method, - const ObjcMethodDecl *PrevMethod) { - if (Method->getResultType().getCanonicalType() != - PrevMethod->getResultType().getCanonicalType()) - return false; - for (int i = 0; i < Method->getNumParams(); i++) { - ParmVarDecl *ParamDecl = Method->getParamDecl(i); - ParmVarDecl *PrevParamDecl = PrevMethod->getParamDecl(i); - if (ParamDecl->getCanonicalType() != PrevParamDecl->getCanonicalType()) - return false; - } - return true; -} - -void Sema::AddInstanceMethodToGlobalPool(ObjcMethodDecl *Method) { - ObjcMethodList &FirstMethod = InstanceMethodPool[Method->getSelector()]; - if (!FirstMethod.Method) { - // Haven't seen a method with this selector name yet - add it. - FirstMethod.Method = Method; - FirstMethod.Next = 0; - } else { - // We've seen a method with this name, now check the type signature(s). - bool match = MatchTwoMethodDeclarations(Method, FirstMethod.Method); - - for (ObjcMethodList *Next = FirstMethod.Next; !match && Next; - Next = Next->Next) - match = MatchTwoMethodDeclarations(Method, Next->Method); - - if (!match) { - // We have a new signature for an existing method - add it. - // This is extremely rare. Only 1% of Cocoa selectors are "overloaded". - struct ObjcMethodList *OMI = new ObjcMethodList(Method, FirstMethod.Next); - FirstMethod.Next = OMI; - } - } -} - -void Sema::AddFactoryMethodToGlobalPool(ObjcMethodDecl *Method) { - ObjcMethodList &FirstMethod = FactoryMethodPool[Method->getSelector()]; - if (!FirstMethod.Method) { - // Haven't seen a method with this selector name yet - add it. - FirstMethod.Method = Method; - FirstMethod.Next = 0; - } else { - // We've seen a method with this name, now check the type signature(s). - bool match = MatchTwoMethodDeclarations(Method, FirstMethod.Method); - - for (ObjcMethodList *Next = FirstMethod.Next; !match && Next; - Next = Next->Next) - match = MatchTwoMethodDeclarations(Method, Next->Method); - - if (!match) { - // We have a new signature for an existing method - add it. - // This is extremely rare. Only 1% of Cocoa selectors are "overloaded". - struct ObjcMethodList *OMI = new ObjcMethodList(Method, FirstMethod.Next); - FirstMethod.Next = OMI; - } - } -} - -void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl, - DeclTy **allMethods, unsigned allNum, - DeclTy **allProperties, unsigned pNum) { - Decl *ClassDecl = static_cast(classDecl); - - // FIXME: If we don't have a ClassDecl, we have an error. I (snaroff) would - // prefer we always pass in a decl. If the decl has an error, isInvalidDecl() - // should be true. - if (!ClassDecl) - return; - - llvm::SmallVector insMethods; - llvm::SmallVector clsMethods; - - llvm::DenseMap InsMap; - llvm::DenseMap ClsMap; - - bool isInterfaceDeclKind = - (isa(ClassDecl) || isa(ClassDecl) - || isa(ClassDecl)); - bool checkIdenticalMethods = isa(ClassDecl); - - // TODO: property declaration in category and protocols. - if (pNum != 0 && isa(ClassDecl)) { - ObjcPropertyDecl **properties = new ObjcPropertyDecl*[pNum]; - memcpy(properties, allProperties, pNum*sizeof(ObjcPropertyDecl*)); - dyn_cast(ClassDecl)->setPropertyDecls(properties); - dyn_cast(ClassDecl)->setNumPropertyDecl(pNum); - } - - for (unsigned i = 0; i < allNum; i++ ) { - ObjcMethodDecl *Method = - cast_or_null(static_cast(allMethods[i])); - - if (!Method) continue; // Already issued a diagnostic. - if (Method->isInstance()) { - /// Check for instance method of the same name with incompatible types - const ObjcMethodDecl *&PrevMethod = InsMap[Method->getSelector()]; - bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod) - : false; - if (isInterfaceDeclKind && PrevMethod && !match - || checkIdenticalMethods && match) { - Diag(Method->getLocation(), diag::error_duplicate_method_decl, - Method->getSelector().getName()); - Diag(PrevMethod->getLocation(), diag::err_previous_declaration); - } else { - insMethods.push_back(Method); - InsMap[Method->getSelector()] = Method; - /// The following allows us to typecheck messages to "id". - AddInstanceMethodToGlobalPool(Method); - } - } - else { - /// Check for class method of the same name with incompatible types - const ObjcMethodDecl *&PrevMethod = ClsMap[Method->getSelector()]; - bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod) - : false; - if (isInterfaceDeclKind && PrevMethod && !match - || checkIdenticalMethods && match) { - Diag(Method->getLocation(), diag::error_duplicate_method_decl, - Method->getSelector().getName()); - Diag(PrevMethod->getLocation(), diag::err_previous_declaration); - } else { - clsMethods.push_back(Method); - ClsMap[Method->getSelector()] = Method; - /// The following allows us to typecheck messages to "id". - AddInstanceMethodToGlobalPool(Method); - } - } - } - - if (ObjcInterfaceDecl *I = dyn_cast(ClassDecl)) { - I->addMethods(&insMethods[0], insMethods.size(), - &clsMethods[0], clsMethods.size(), AtEndLoc); - } else if (ObjcProtocolDecl *P = dyn_cast(ClassDecl)) { - P->addMethods(&insMethods[0], insMethods.size(), - &clsMethods[0], clsMethods.size(), AtEndLoc); - } - else if (ObjcCategoryDecl *C = dyn_cast(ClassDecl)) { - C->addMethods(&insMethods[0], insMethods.size(), - &clsMethods[0], clsMethods.size(), AtEndLoc); - } - else if (ObjcImplementationDecl *IC = - dyn_cast(ClassDecl)) { - IC->setLocEnd(AtEndLoc); - if (ObjcInterfaceDecl* IDecl = getObjCInterfaceDecl(IC->getIdentifier())) - ImplMethodsVsClassMethods(IC, IDecl); - } else { - ObjcCategoryImplDecl* CatImplClass = cast(ClassDecl); - CatImplClass->setLocEnd(AtEndLoc); - ObjcInterfaceDecl* IDecl = CatImplClass->getClassInterface(); - // Find category interface decl and then check that all methods declared - // in this interface is implemented in the category @implementation. - if (IDecl) { - for (ObjcCategoryDecl *Categories = IDecl->getCategoryList(); - Categories; Categories = Categories->getNextClassCategory()) { - if (Categories->getIdentifier() == CatImplClass->getIdentifier()) { - ImplCategoryMethodsVsIntfMethods(CatImplClass, Categories); - break; - } - } - } - } -} - -/// CvtQTToAstBitMask - utility routine to produce an AST bitmask for -/// objective-c's type qualifier from the parser version of the same info. -static Decl::ObjcDeclQualifier -CvtQTToAstBitMask(ObjcDeclSpec::ObjcDeclQualifier PQTVal) { - Decl::ObjcDeclQualifier ret = Decl::OBJC_TQ_None; - if (PQTVal & ObjcDeclSpec::DQ_In) - ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_In); - if (PQTVal & ObjcDeclSpec::DQ_Inout) - ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Inout); - if (PQTVal & ObjcDeclSpec::DQ_Out) - ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Out); - if (PQTVal & ObjcDeclSpec::DQ_Bycopy) - ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Bycopy); - if (PQTVal & ObjcDeclSpec::DQ_Byref) - ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Byref); - if (PQTVal & ObjcDeclSpec::DQ_Oneway) - ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Oneway); - - return ret; -} - -Sema::DeclTy *Sema::ActOnMethodDeclaration( - SourceLocation MethodLoc, SourceLocation EndLoc, - tok::TokenKind MethodType, DeclTy *ClassDecl, - ObjcDeclSpec &ReturnQT, TypeTy *ReturnType, - Selector Sel, - // optional arguments. The number of types/arguments is obtained - // from the Sel.getNumArgs(). - ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames, - AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind, - bool isVariadic) { - llvm::SmallVector Params; - - for (unsigned i = 0; i < Sel.getNumArgs(); i++) { - // FIXME: arg->AttrList must be stored too! - QualType argType; - - if (ArgTypes[i]) - argType = QualType::getFromOpaquePtr(ArgTypes[i]); - else - argType = Context.getObjcIdType(); - ParmVarDecl* Param = new ParmVarDecl(SourceLocation(/*FIXME*/), ArgNames[i], - argType, VarDecl::None, 0); - Param->setObjcDeclQualifier( - CvtQTToAstBitMask(ArgQT[i].getObjcDeclQualifier())); - Params.push_back(Param); - } - QualType resultDeclType; - - if (ReturnType) - resultDeclType = QualType::getFromOpaquePtr(ReturnType); - else // get the type for "id". - resultDeclType = Context.getObjcIdType(); - - Decl *CDecl = static_cast(ClassDecl); - ObjcMethodDecl* ObjcMethod = new ObjcMethodDecl(MethodLoc, EndLoc, Sel, - resultDeclType, - CDecl, - 0, -1, AttrList, - MethodType == tok::minus, isVariadic, - MethodDeclKind == tok::objc_optional ? - ObjcMethodDecl::Optional : - ObjcMethodDecl::Required); - ObjcMethod->setMethodParams(&Params[0], Sel.getNumArgs()); - ObjcMethod->setObjcDeclQualifier( - CvtQTToAstBitMask(ReturnQT.getObjcDeclQualifier())); - const ObjcMethodDecl *PrevMethod = 0; - - // For implementations (which can be very "coarse grain"), we add the - // method now. This allows the AST to implement lookup methods that work - // incrementally (without waiting until we parse the @end). It also allows - // us to flag multiple declaration errors as they occur. - if (ObjcImplementationDecl *ImpDecl = - dyn_cast(CDecl)) { - if (MethodType == tok::minus) { - PrevMethod = ImpDecl->lookupInstanceMethod(Sel); - ImpDecl->addInstanceMethod(ObjcMethod); - } else { - PrevMethod = ImpDecl->lookupClassMethod(Sel); - ImpDecl->addClassMethod(ObjcMethod); - } - } - else if (ObjcCategoryImplDecl *CatImpDecl = - dyn_cast(CDecl)) { - if (MethodType == tok::minus) { - PrevMethod = CatImpDecl->lookupInstanceMethod(Sel); - CatImpDecl->addInstanceMethod(ObjcMethod); - } else { - PrevMethod = CatImpDecl->lookupClassMethod(Sel); - CatImpDecl->addClassMethod(ObjcMethod); - } - } - if (PrevMethod) { - // You can never have two method definitions with the same name. - Diag(ObjcMethod->getLocation(), diag::error_duplicate_method_decl, - ObjcMethod->getSelector().getName()); - Diag(PrevMethod->getLocation(), diag::err_previous_declaration); - } - return ObjcMethod; -} - -Sema::DeclTy *Sema::ActOnAddObjcProperties(SourceLocation AtLoc, - DeclTy **allProperties, unsigned NumProperties, ObjcDeclSpec &DS) { - ObjcPropertyDecl *PDecl = new ObjcPropertyDecl(AtLoc); - - if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_readonly) - PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_readonly); - - if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_getter) { - PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_getter); - PDecl->setGetterName(DS.getGetterName()); - } - - if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_setter) { - PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_setter); - PDecl->setSetterName(DS.getSetterName()); - } - - if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_assign) - PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_assign); - - if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_readwrite) - PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_readwrite); - - if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_retain) - PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_retain); - - if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_copy) - PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_copy); - - if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_nonatomic) - PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_nonatomic); - - PDecl->setNumPropertyDecls(NumProperties); - if (NumProperties != 0) { - ObjcIvarDecl **properties = new ObjcIvarDecl*[NumProperties]; - memcpy(properties, allProperties, NumProperties*sizeof(ObjcIvarDecl*)); - PDecl->setPropertyDecls(properties); - } - return PDecl; -} - Sema::DeclTy *Sema::ActOnEnumConstant(Scope *S, DeclTy *theEnumDecl, DeclTy *lastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Added: cfe/trunk/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDeclObjC.cpp?rev=44925&view=auto ============================================================================== --- cfe/trunk/Sema/SemaDeclObjC.cpp (added) +++ cfe/trunk/Sema/SemaDeclObjC.cpp Wed Dec 12 01:09:47 2007 @@ -0,0 +1,914 @@ +//===--- SemaDeclObjC.cpp - Semantic Analysis for ObjC Declarations -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Chris Lattner and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements semantic analysis for Objective C declarations. +// +//===----------------------------------------------------------------------===// + +#include "Sema.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/DeclObjC.h" +#include "clang/Parse/Scope.h" + +using namespace clang; + +/// ObjcActOnStartOfMethodDef - This routine sets up parameters; invisible +/// and user declared, in the method definition's AST. +void Sema::ObjcActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { + assert(CurFunctionDecl == 0 && "Method parsing confused"); + ObjcMethodDecl *MDecl = dyn_cast(static_cast(D)); + assert(MDecl != 0 && "Not a method declarator!"); + + // Allow all of Sema to see that we are entering a method definition. + CurMethodDecl = MDecl; + + // Create Decl objects for each parameter, entrring them in the scope for + // binding to their use. + struct DeclaratorChunk::ParamInfo PI; + + // Insert the invisible arguments, self and _cmd! + PI.Ident = &Context.Idents.get("self"); + PI.IdentLoc = SourceLocation(); // synthesized vars have a null location. + PI.InvalidType = false; + if (MDecl->isInstance()) { + QualType selfTy = Context.getObjcInterfaceType(MDecl->getClassInterface()); + selfTy = Context.getPointerType(selfTy); + PI.TypeInfo = selfTy.getAsOpaquePtr(); + } else + PI.TypeInfo = Context.getObjcIdType().getAsOpaquePtr(); + CurMethodDecl->setSelfDecl(ActOnParamDeclarator(PI, FnBodyScope)); + + PI.Ident = &Context.Idents.get("_cmd"); + PI.TypeInfo = Context.getObjcSelType().getAsOpaquePtr(); + ActOnParamDeclarator(PI, FnBodyScope); + + for (int i = 0; i < MDecl->getNumParams(); i++) { + ParmVarDecl *PDecl = MDecl->getParamDecl(i); + PI.Ident = PDecl->getIdentifier(); + PI.IdentLoc = PDecl->getLocation(); // user vars have a real location. + PI.TypeInfo = PDecl->getType().getAsOpaquePtr(); + ActOnParamDeclarator(PI, FnBodyScope); + } +} + +Sema::DeclTy *Sema::ActOnStartClassInterface( + SourceLocation AtInterfaceLoc, + IdentifierInfo *ClassName, SourceLocation ClassLoc, + IdentifierInfo *SuperName, SourceLocation SuperLoc, + IdentifierInfo **ProtocolNames, unsigned NumProtocols, + SourceLocation EndProtoLoc, AttributeList *AttrList) { + assert(ClassName && "Missing class identifier"); + + // Check for another declaration kind with the same name. + ScopedDecl *PrevDecl = LookupInterfaceDecl(ClassName); + if (PrevDecl && !isa(PrevDecl)) { + Diag(ClassLoc, diag::err_redefinition_different_kind, + ClassName->getName()); + Diag(PrevDecl->getLocation(), diag::err_previous_definition); + } + + ObjcInterfaceDecl* IDecl = dyn_cast_or_null(PrevDecl); + if (IDecl) { + // Class already seen. Is it a forward declaration? + if (!IDecl->isForwardDecl()) + Diag(AtInterfaceLoc, diag::err_duplicate_class_def, IDecl->getName()); + else { + IDecl->setLocation(AtInterfaceLoc); + IDecl->setForwardDecl(false); + IDecl->AllocIntfRefProtocols(NumProtocols); + } + } + else { + IDecl = new ObjcInterfaceDecl(AtInterfaceLoc, NumProtocols, ClassName); + + // Chain & install the interface decl into the identifier. + IDecl->setNext(ClassName->getFETokenInfo()); + ClassName->setFETokenInfo(IDecl); + + // Remember that this needs to be removed when the scope is popped. + TUScope->AddDecl(IDecl); + } + + if (SuperName) { + ObjcInterfaceDecl* SuperClassEntry = 0; + // Check if a different kind of symbol declared in this scope. + PrevDecl = LookupInterfaceDecl(SuperName); + if (PrevDecl && !isa(PrevDecl)) { + Diag(SuperLoc, diag::err_redefinition_different_kind, + SuperName->getName()); + Diag(PrevDecl->getLocation(), diag::err_previous_definition); + } + else { + // Check that super class is previously defined + SuperClassEntry = dyn_cast_or_null(PrevDecl); + + if (!SuperClassEntry || SuperClassEntry->isForwardDecl()) { + Diag(AtInterfaceLoc, diag::err_undef_superclass, + SuperClassEntry ? SuperClassEntry->getName() + : SuperName->getName(), + ClassName->getName()); + } + } + IDecl->setSuperClass(SuperClassEntry); + IDecl->setLocEnd(SuperLoc); + } else { // we have a root class. + IDecl->setLocEnd(ClassLoc); + } + + /// Check then save referenced protocols + if (NumProtocols) { + for (unsigned int i = 0; i != NumProtocols; i++) { + ObjcProtocolDecl* RefPDecl = ObjcProtocols[ProtocolNames[i]]; + if (!RefPDecl || RefPDecl->isForwardDecl()) + Diag(ClassLoc, diag::warn_undef_protocolref, + ProtocolNames[i]->getName(), + ClassName->getName()); + IDecl->setIntfRefProtocols((int)i, RefPDecl); + } + IDecl->setLocEnd(EndProtoLoc); + } + return IDecl; +} + +/// ActOnCompatiblityAlias - this action is called after complete parsing of +/// @compaatibility_alias declaration. It sets up the alias relationships. +Sema::DeclTy *Sema::ActOnCompatiblityAlias( + SourceLocation AtCompatibilityAliasLoc, + IdentifierInfo *AliasName, SourceLocation AliasLocation, + IdentifierInfo *ClassName, SourceLocation ClassLocation) { + // Look for previous declaration of alias name + ScopedDecl *ADecl = LookupScopedDecl(AliasName, Decl::IDNS_Ordinary, + AliasLocation, TUScope); + if (ADecl) { + if (isa(ADecl)) { + Diag(AliasLocation, diag::warn_previous_alias_decl); + Diag(ADecl->getLocation(), diag::warn_previous_declaration); + } + else { + Diag(AliasLocation, diag::err_conflicting_aliasing_type, + AliasName->getName()); + Diag(ADecl->getLocation(), diag::err_previous_declaration); + } + return 0; + } + // Check for class declaration + ScopedDecl *CDecl = LookupScopedDecl(ClassName, Decl::IDNS_Ordinary, + ClassLocation, TUScope); + if (!CDecl || !isa(CDecl)) { + Diag(ClassLocation, diag::warn_undef_interface, + ClassName->getName()); + if (CDecl) + Diag(CDecl->getLocation(), diag::warn_previous_declaration); + return 0; + } + // Everything checked out, instantiate a new alias declaration ast + ObjcCompatibleAliasDecl *AliasDecl = + new ObjcCompatibleAliasDecl(AtCompatibilityAliasLoc, + AliasName, + dyn_cast(CDecl)); + + // Chain & install the interface decl into the identifier. + AliasDecl->setNext(AliasName->getFETokenInfo()); + AliasName->setFETokenInfo(AliasDecl); + return AliasDecl; +} + +Sema::DeclTy *Sema::ActOnStartProtocolInterface( + SourceLocation AtProtoInterfaceLoc, + IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, + IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs, + SourceLocation EndProtoLoc) { + assert(ProtocolName && "Missing protocol identifier"); + ObjcProtocolDecl *PDecl = ObjcProtocols[ProtocolName]; + if (PDecl) { + // Protocol already seen. Better be a forward protocol declaration + if (!PDecl->isForwardDecl()) + Diag(ProtocolLoc, diag::err_duplicate_protocol_def, + ProtocolName->getName()); + else { + PDecl->setForwardDecl(false); + PDecl->AllocReferencedProtocols(NumProtoRefs); + } + } + else { + PDecl = new ObjcProtocolDecl(AtProtoInterfaceLoc, NumProtoRefs, + ProtocolName); + ObjcProtocols[ProtocolName] = PDecl; + } + + if (NumProtoRefs) { + /// Check then save referenced protocols + for (unsigned int i = 0; i != NumProtoRefs; i++) { + ObjcProtocolDecl* RefPDecl = ObjcProtocols[ProtoRefNames[i]]; + if (!RefPDecl || RefPDecl->isForwardDecl()) + Diag(ProtocolLoc, diag::warn_undef_protocolref, + ProtoRefNames[i]->getName(), + ProtocolName->getName()); + PDecl->setReferencedProtocols((int)i, RefPDecl); + } + PDecl->setLocEnd(EndProtoLoc); + } + return PDecl; +} + +/// FindProtocolDeclaration - This routine looks up protocols and +/// issuer error if they are not declared. It returns list of protocol +/// declarations in its 'Protocols' argument. +void +Sema::FindProtocolDeclaration(SourceLocation TypeLoc, + IdentifierInfo **ProtocolId, + unsigned NumProtocols, + llvm::SmallVector &Protocols) { + for (unsigned i = 0; i != NumProtocols; ++i) { + ObjcProtocolDecl *PDecl = ObjcProtocols[ProtocolId[i]]; + if (!PDecl) + Diag(TypeLoc, diag::err_undeclared_protocol, + ProtocolId[i]->getName()); + else + Protocols.push_back(PDecl); + } +} + +/// ActOnForwardProtocolDeclaration - +Action::DeclTy * +Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, + IdentifierInfo **IdentList, unsigned NumElts) { + llvm::SmallVector Protocols; + + for (unsigned i = 0; i != NumElts; ++i) { + IdentifierInfo *P = IdentList[i]; + ObjcProtocolDecl *PDecl = ObjcProtocols[P]; + if (!PDecl) { // Not already seen? + // FIXME: Pass in the location of the identifier! + PDecl = new ObjcProtocolDecl(AtProtocolLoc, 0, P, true); + ObjcProtocols[P] = PDecl; + } + + Protocols.push_back(PDecl); + } + return new ObjcForwardProtocolDecl(AtProtocolLoc, + &Protocols[0], Protocols.size()); +} + +Sema::DeclTy *Sema::ActOnStartCategoryInterface( + SourceLocation AtInterfaceLoc, + IdentifierInfo *ClassName, SourceLocation ClassLoc, + IdentifierInfo *CategoryName, SourceLocation CategoryLoc, + IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs, + SourceLocation EndProtoLoc) { + ObjcInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); + + /// Check that class of this category is already completely declared. + if (!IDecl || IDecl->isForwardDecl()) { + Diag(ClassLoc, diag::err_undef_interface, ClassName->getName()); + return 0; + } + ObjcCategoryDecl *CDecl = new ObjcCategoryDecl(AtInterfaceLoc, NumProtoRefs, + CategoryName); + CDecl->setClassInterface(IDecl); + /// Check for duplicate interface declaration for this category + ObjcCategoryDecl *CDeclChain; + for (CDeclChain = IDecl->getCategoryList(); CDeclChain; + CDeclChain = CDeclChain->getNextClassCategory()) { + if (CDeclChain->getIdentifier() == CategoryName) { + Diag(CategoryLoc, diag::err_dup_category_def, ClassName->getName(), + CategoryName->getName()); + break; + } + } + if (!CDeclChain) + CDecl->insertNextClassCategory(); + + if (NumProtoRefs) { + /// Check then save referenced protocols + for (unsigned int i = 0; i != NumProtoRefs; i++) { + ObjcProtocolDecl* RefPDecl = ObjcProtocols[ProtoRefNames[i]]; + if (!RefPDecl || RefPDecl->isForwardDecl()) { + Diag(CategoryLoc, diag::warn_undef_protocolref, + ProtoRefNames[i]->getName(), + CategoryName->getName()); + } + CDecl->setCatReferencedProtocols((int)i, RefPDecl); + } + CDecl->setLocEnd(EndProtoLoc); + } + return CDecl; +} + +/// ActOnStartCategoryImplementation - Perform semantic checks on the +/// category implementation declaration and build an ObjcCategoryImplDecl +/// object. +Sema::DeclTy *Sema::ActOnStartCategoryImplementation( + SourceLocation AtCatImplLoc, + IdentifierInfo *ClassName, SourceLocation ClassLoc, + IdentifierInfo *CatName, SourceLocation CatLoc) { + ObjcInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName); + ObjcCategoryImplDecl *CDecl = new ObjcCategoryImplDecl(AtCatImplLoc, + CatName, IDecl); + /// Check that class of this category is already completely declared. + if (!IDecl || IDecl->isForwardDecl()) + Diag(ClassLoc, diag::err_undef_interface, ClassName->getName()); + + /// TODO: Check that CatName, category name, is not used in another + // implementation. + return CDecl; +} + +Sema::DeclTy *Sema::ActOnStartClassImplementation( + SourceLocation AtClassImplLoc, + IdentifierInfo *ClassName, SourceLocation ClassLoc, + IdentifierInfo *SuperClassname, + SourceLocation SuperClassLoc) { + ObjcInterfaceDecl* IDecl = 0; + // Check for another declaration kind with the same name. + ScopedDecl *PrevDecl = LookupInterfaceDecl(ClassName); + if (PrevDecl && !isa(PrevDecl)) { + Diag(ClassLoc, diag::err_redefinition_different_kind, + ClassName->getName()); + Diag(PrevDecl->getLocation(), diag::err_previous_definition); + } + else { + // Is there an interface declaration of this class; if not, warn! + IDecl = dyn_cast_or_null(PrevDecl); + if (!IDecl) + Diag(ClassLoc, diag::warn_undef_interface, ClassName->getName()); + } + + // Check that super class name is valid class name + ObjcInterfaceDecl* SDecl = 0; + if (SuperClassname) { + // Check if a different kind of symbol declared in this scope. + PrevDecl = LookupInterfaceDecl(SuperClassname); + if (PrevDecl && !isa(PrevDecl)) { + Diag(SuperClassLoc, diag::err_redefinition_different_kind, + SuperClassname->getName()); + Diag(PrevDecl->getLocation(), diag::err_previous_definition); + } + else { + SDecl = dyn_cast_or_null(PrevDecl); + if (!SDecl) + Diag(SuperClassLoc, diag::err_undef_superclass, + SuperClassname->getName(), ClassName->getName()); + else if (IDecl && IDecl->getSuperClass() != SDecl) { + // This implementation and its interface do not have the same + // super class. + Diag(SuperClassLoc, diag::err_conflicting_super_class, + SDecl->getName()); + Diag(SDecl->getLocation(), diag::err_previous_definition); + } + } + } + + if (!IDecl) { + // Legacy case of @implementation with no corresponding @interface. + // Build, chain & install the interface decl into the identifier. + IDecl = new ObjcInterfaceDecl(AtClassImplLoc, 0, ClassName, + false, true); + IDecl->setNext(ClassName->getFETokenInfo()); + ClassName->setFETokenInfo(IDecl); + IDecl->setSuperClass(SDecl); + IDecl->setLocEnd(ClassLoc); + + // Remember that this needs to be removed when the scope is popped. + TUScope->AddDecl(IDecl); + } + + ObjcImplementationDecl* IMPDecl = + new ObjcImplementationDecl(AtClassImplLoc, ClassName, IDecl, SDecl); + + // Check that there is no duplicate implementation of this class. + if (ObjcImplementations[ClassName]) + Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName()); + else // add it to the list. + ObjcImplementations[ClassName] = IMPDecl; + return IMPDecl; +} + +void Sema::CheckImplementationIvars(ObjcImplementationDecl *ImpDecl, + ObjcIvarDecl **ivars, unsigned numIvars, + SourceLocation RBrace) { + assert(ImpDecl && "missing implementation decl"); + ObjcInterfaceDecl* IDecl = getObjCInterfaceDecl(ImpDecl->getIdentifier()); + if (!IDecl) + return; + /// Check case of non-existing @interface decl. + /// (legacy objective-c @implementation decl without an @interface decl). + /// Add implementations's ivar to the synthesize class's ivar list. + if (IDecl->ImplicitInterfaceDecl()) { + IDecl->addInstanceVariablesToClass(ivars, numIvars, RBrace); + return; + } + // If implementation has empty ivar list, just return. + if (numIvars == 0) + return; + + assert(ivars && "missing @implementation ivars"); + + // Check interface's Ivar list against those in the implementation. + // names and types must match. + // + ObjcIvarDecl** IntfIvars = IDecl->getInstanceVariables(); + int IntfNumIvars = IDecl->getNumInstanceVariables(); + unsigned j = 0; + bool err = false; + while (numIvars > 0 && IntfNumIvars > 0) { + ObjcIvarDecl* ImplIvar = ivars[j]; + ObjcIvarDecl* ClsIvar = IntfIvars[j++]; + assert (ImplIvar && "missing implementation ivar"); + assert (ClsIvar && "missing class ivar"); + if (ImplIvar->getCanonicalType() != ClsIvar->getCanonicalType()) { + Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_type, + ImplIvar->getIdentifier()->getName()); + Diag(ClsIvar->getLocation(), diag::err_previous_definition, + ClsIvar->getIdentifier()->getName()); + } + // TODO: Two mismatched (unequal width) Ivar bitfields should be diagnosed + // as error. + else if (ImplIvar->getIdentifier() != ClsIvar->getIdentifier()) { + Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_name, + ImplIvar->getIdentifier()->getName()); + Diag(ClsIvar->getLocation(), diag::err_previous_definition, + ClsIvar->getIdentifier()->getName()); + err = true; + break; + } + --numIvars; + --IntfNumIvars; + } + if (!err && (numIvars > 0 || IntfNumIvars > 0)) + Diag(numIvars > 0 ? ivars[j]->getLocation() : IntfIvars[j]->getLocation(), + diag::err_inconsistant_ivar); + +} + +/// CheckProtocolMethodDefs - This routine checks unimpletented methods +/// Declared in protocol, and those referenced by it. +void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl, + bool& IncompleteImpl, + const llvm::DenseSet &InsMap, + const llvm::DenseSet &ClsMap) { + // check unimplemented instance methods. + ObjcMethodDecl** methods = PDecl->getInstanceMethods(); + for (int j = 0; j < PDecl->getNumInstanceMethods(); j++) { + if (!InsMap.count(methods[j]->getSelector()) && + methods[j]->getImplementationControl() != ObjcMethodDecl::Optional) { + Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, + methods[j]->getSelector().getName()); + IncompleteImpl = true; + } + } + // check unimplemented class methods + methods = PDecl->getClassMethods(); + for (int j = 0; j < PDecl->getNumClassMethods(); j++) + if (!ClsMap.count(methods[j]->getSelector()) && + methods[j]->getImplementationControl() != ObjcMethodDecl::Optional) { + Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, + methods[j]->getSelector().getName()); + IncompleteImpl = true; + } + + // Check on this protocols's referenced protocols, recursively + ObjcProtocolDecl** RefPDecl = PDecl->getReferencedProtocols(); + for (int i = 0; i < PDecl->getNumReferencedProtocols(); i++) + CheckProtocolMethodDefs(RefPDecl[i], IncompleteImpl, InsMap, ClsMap); +} + +void Sema::ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl, + ObjcInterfaceDecl* IDecl) { + llvm::DenseSet InsMap; + // Check and see if instance methods in class interface have been + // implemented in the implementation class. + ObjcMethodDecl *const*methods = IMPDecl->getInstanceMethods(); + for (int i=0; i < IMPDecl->getNumInstanceMethods(); i++) + InsMap.insert(methods[i]->getSelector()); + + bool IncompleteImpl = false; + methods = IDecl->getInstanceMethods(); + for (int j = 0; j < IDecl->getNumInstanceMethods(); j++) + if (!InsMap.count(methods[j]->getSelector())) { + Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, + methods[j]->getSelector().getName()); + IncompleteImpl = true; + } + llvm::DenseSet ClsMap; + // Check and see if class methods in class interface have been + // implemented in the implementation class. + methods = IMPDecl->getClassMethods(); + for (int i=0; i < IMPDecl->getNumClassMethods(); i++) + ClsMap.insert(methods[i]->getSelector()); + + methods = IDecl->getClassMethods(); + for (int j = 0; j < IDecl->getNumClassMethods(); j++) + if (!ClsMap.count(methods[j]->getSelector())) { + Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, + methods[j]->getSelector().getName()); + IncompleteImpl = true; + } + + // Check the protocol list for unimplemented methods in the @implementation + // class. + ObjcProtocolDecl** protocols = IDecl->getReferencedProtocols(); + for (int i = 0; i < IDecl->getNumIntfRefProtocols(); i++) + CheckProtocolMethodDefs(protocols[i], IncompleteImpl, InsMap, ClsMap); + + if (IncompleteImpl) + Diag(IMPDecl->getLocation(), diag::warn_incomplete_impl_class, + IMPDecl->getName()); +} + +/// ImplCategoryMethodsVsIntfMethods - Checks that methods declared in the +/// category interface is implemented in the category @implementation. +void Sema::ImplCategoryMethodsVsIntfMethods(ObjcCategoryImplDecl *CatImplDecl, + ObjcCategoryDecl *CatClassDecl) { + llvm::DenseSet InsMap; + // Check and see if instance methods in category interface have been + // implemented in its implementation class. + ObjcMethodDecl *const*methods = CatImplDecl->getInstanceMethods(); + for (int i=0; i < CatImplDecl->getNumInstanceMethods(); i++) + InsMap.insert(methods[i]->getSelector()); + + bool IncompleteImpl = false; + methods = CatClassDecl->getInstanceMethods(); + for (int j = 0; j < CatClassDecl->getNumInstanceMethods(); j++) + if (!InsMap.count(methods[j]->getSelector())) { + Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, + methods[j]->getSelector().getName()); + IncompleteImpl = true; + } + llvm::DenseSet ClsMap; + // Check and see if class methods in category interface have been + // implemented in its implementation class. + methods = CatImplDecl->getClassMethods(); + for (int i=0; i < CatImplDecl->getNumClassMethods(); i++) + ClsMap.insert(methods[i]->getSelector()); + + methods = CatClassDecl->getClassMethods(); + for (int j = 0; j < CatClassDecl->getNumClassMethods(); j++) + if (!ClsMap.count(methods[j]->getSelector())) { + Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, + methods[j]->getSelector().getName()); + IncompleteImpl = true; + } + + // Check the protocol list for unimplemented methods in the @implementation + // class. + ObjcProtocolDecl** protocols = CatClassDecl->getReferencedProtocols(); + for (int i = 0; i < CatClassDecl->getNumReferencedProtocols(); i++) { + ObjcProtocolDecl* PDecl = protocols[i]; + CheckProtocolMethodDefs(PDecl, IncompleteImpl, InsMap, ClsMap); + } + if (IncompleteImpl) + Diag(CatImplDecl->getLocation(), diag::warn_incomplete_impl_category, + CatClassDecl->getName()); +} + +/// ActOnForwardClassDeclaration - +Action::DeclTy * +Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, + IdentifierInfo **IdentList, unsigned NumElts) +{ + llvm::SmallVector Interfaces; + + for (unsigned i = 0; i != NumElts; ++i) { + // Check for another declaration kind with the same name. + ScopedDecl *PrevDecl = LookupInterfaceDecl(IdentList[i]); + if (PrevDecl && !isa(PrevDecl)) { + Diag(AtClassLoc, diag::err_redefinition_different_kind, + IdentList[i]->getName()); + Diag(PrevDecl->getLocation(), diag::err_previous_definition); + } + ObjcInterfaceDecl *IDecl = dyn_cast_or_null(PrevDecl); + if (!IDecl) { // Not already seen? Make a forward decl. + IDecl = new ObjcInterfaceDecl(AtClassLoc, 0, IdentList[i], true); + // Chain & install the interface decl into the identifier. + IDecl->setNext(IdentList[i]->getFETokenInfo()); + IdentList[i]->setFETokenInfo(IDecl); + + // Remember that this needs to be removed when the scope is popped. + TUScope->AddDecl(IDecl); + } + + Interfaces.push_back(IDecl); + } + + return new ObjcClassDecl(AtClassLoc, &Interfaces[0], Interfaces.size()); +} + + +/// MatchTwoMethodDeclarations - Checks that two methods have matching type and +/// returns true, or false, accordingly. +/// TODO: Handle protocol list; such as id in type comparisons +bool Sema::MatchTwoMethodDeclarations(const ObjcMethodDecl *Method, + const ObjcMethodDecl *PrevMethod) { + if (Method->getResultType().getCanonicalType() != + PrevMethod->getResultType().getCanonicalType()) + return false; + for (int i = 0; i < Method->getNumParams(); i++) { + ParmVarDecl *ParamDecl = Method->getParamDecl(i); + ParmVarDecl *PrevParamDecl = PrevMethod->getParamDecl(i); + if (ParamDecl->getCanonicalType() != PrevParamDecl->getCanonicalType()) + return false; + } + return true; +} + +void Sema::AddInstanceMethodToGlobalPool(ObjcMethodDecl *Method) { + ObjcMethodList &FirstMethod = InstanceMethodPool[Method->getSelector()]; + if (!FirstMethod.Method) { + // Haven't seen a method with this selector name yet - add it. + FirstMethod.Method = Method; + FirstMethod.Next = 0; + } else { + // We've seen a method with this name, now check the type signature(s). + bool match = MatchTwoMethodDeclarations(Method, FirstMethod.Method); + + for (ObjcMethodList *Next = FirstMethod.Next; !match && Next; + Next = Next->Next) + match = MatchTwoMethodDeclarations(Method, Next->Method); + + if (!match) { + // We have a new signature for an existing method - add it. + // This is extremely rare. Only 1% of Cocoa selectors are "overloaded". + struct ObjcMethodList *OMI = new ObjcMethodList(Method, FirstMethod.Next); + FirstMethod.Next = OMI; + } + } +} + +void Sema::AddFactoryMethodToGlobalPool(ObjcMethodDecl *Method) { + ObjcMethodList &FirstMethod = FactoryMethodPool[Method->getSelector()]; + if (!FirstMethod.Method) { + // Haven't seen a method with this selector name yet - add it. + FirstMethod.Method = Method; + FirstMethod.Next = 0; + } else { + // We've seen a method with this name, now check the type signature(s). + bool match = MatchTwoMethodDeclarations(Method, FirstMethod.Method); + + for (ObjcMethodList *Next = FirstMethod.Next; !match && Next; + Next = Next->Next) + match = MatchTwoMethodDeclarations(Method, Next->Method); + + if (!match) { + // We have a new signature for an existing method - add it. + // This is extremely rare. Only 1% of Cocoa selectors are "overloaded". + struct ObjcMethodList *OMI = new ObjcMethodList(Method, FirstMethod.Next); + FirstMethod.Next = OMI; + } + } +} + +void Sema::ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl, + DeclTy **allMethods, unsigned allNum, + DeclTy **allProperties, unsigned pNum) { + Decl *ClassDecl = static_cast(classDecl); + + // FIXME: If we don't have a ClassDecl, we have an error. I (snaroff) would + // prefer we always pass in a decl. If the decl has an error, isInvalidDecl() + // should be true. + if (!ClassDecl) + return; + + llvm::SmallVector insMethods; + llvm::SmallVector clsMethods; + + llvm::DenseMap InsMap; + llvm::DenseMap ClsMap; + + bool isInterfaceDeclKind = + (isa(ClassDecl) || isa(ClassDecl) + || isa(ClassDecl)); + bool checkIdenticalMethods = isa(ClassDecl); + + // TODO: property declaration in category and protocols. + if (pNum != 0 && isa(ClassDecl)) { + ObjcPropertyDecl **properties = new ObjcPropertyDecl*[pNum]; + memcpy(properties, allProperties, pNum*sizeof(ObjcPropertyDecl*)); + dyn_cast(ClassDecl)->setPropertyDecls(properties); + dyn_cast(ClassDecl)->setNumPropertyDecl(pNum); + } + + for (unsigned i = 0; i < allNum; i++ ) { + ObjcMethodDecl *Method = + cast_or_null(static_cast(allMethods[i])); + + if (!Method) continue; // Already issued a diagnostic. + if (Method->isInstance()) { + /// Check for instance method of the same name with incompatible types + const ObjcMethodDecl *&PrevMethod = InsMap[Method->getSelector()]; + bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod) + : false; + if (isInterfaceDeclKind && PrevMethod && !match + || checkIdenticalMethods && match) { + Diag(Method->getLocation(), diag::error_duplicate_method_decl, + Method->getSelector().getName()); + Diag(PrevMethod->getLocation(), diag::err_previous_declaration); + } else { + insMethods.push_back(Method); + InsMap[Method->getSelector()] = Method; + /// The following allows us to typecheck messages to "id". + AddInstanceMethodToGlobalPool(Method); + } + } + else { + /// Check for class method of the same name with incompatible types + const ObjcMethodDecl *&PrevMethod = ClsMap[Method->getSelector()]; + bool match = PrevMethod ? MatchTwoMethodDeclarations(Method, PrevMethod) + : false; + if (isInterfaceDeclKind && PrevMethod && !match + || checkIdenticalMethods && match) { + Diag(Method->getLocation(), diag::error_duplicate_method_decl, + Method->getSelector().getName()); + Diag(PrevMethod->getLocation(), diag::err_previous_declaration); + } else { + clsMethods.push_back(Method); + ClsMap[Method->getSelector()] = Method; + /// The following allows us to typecheck messages to "id". + AddInstanceMethodToGlobalPool(Method); + } + } + } + + if (ObjcInterfaceDecl *I = dyn_cast(ClassDecl)) { + I->addMethods(&insMethods[0], insMethods.size(), + &clsMethods[0], clsMethods.size(), AtEndLoc); + } else if (ObjcProtocolDecl *P = dyn_cast(ClassDecl)) { + P->addMethods(&insMethods[0], insMethods.size(), + &clsMethods[0], clsMethods.size(), AtEndLoc); + } + else if (ObjcCategoryDecl *C = dyn_cast(ClassDecl)) { + C->addMethods(&insMethods[0], insMethods.size(), + &clsMethods[0], clsMethods.size(), AtEndLoc); + } + else if (ObjcImplementationDecl *IC = + dyn_cast(ClassDecl)) { + IC->setLocEnd(AtEndLoc); + if (ObjcInterfaceDecl* IDecl = getObjCInterfaceDecl(IC->getIdentifier())) + ImplMethodsVsClassMethods(IC, IDecl); + } else { + ObjcCategoryImplDecl* CatImplClass = cast(ClassDecl); + CatImplClass->setLocEnd(AtEndLoc); + ObjcInterfaceDecl* IDecl = CatImplClass->getClassInterface(); + // Find category interface decl and then check that all methods declared + // in this interface is implemented in the category @implementation. + if (IDecl) { + for (ObjcCategoryDecl *Categories = IDecl->getCategoryList(); + Categories; Categories = Categories->getNextClassCategory()) { + if (Categories->getIdentifier() == CatImplClass->getIdentifier()) { + ImplCategoryMethodsVsIntfMethods(CatImplClass, Categories); + break; + } + } + } + } +} + + +/// CvtQTToAstBitMask - utility routine to produce an AST bitmask for +/// objective-c's type qualifier from the parser version of the same info. +static Decl::ObjcDeclQualifier +CvtQTToAstBitMask(ObjcDeclSpec::ObjcDeclQualifier PQTVal) { + Decl::ObjcDeclQualifier ret = Decl::OBJC_TQ_None; + if (PQTVal & ObjcDeclSpec::DQ_In) + ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_In); + if (PQTVal & ObjcDeclSpec::DQ_Inout) + ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Inout); + if (PQTVal & ObjcDeclSpec::DQ_Out) + ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Out); + if (PQTVal & ObjcDeclSpec::DQ_Bycopy) + ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Bycopy); + if (PQTVal & ObjcDeclSpec::DQ_Byref) + ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Byref); + if (PQTVal & ObjcDeclSpec::DQ_Oneway) + ret = (Decl::ObjcDeclQualifier)(ret | Decl::OBJC_TQ_Oneway); + + return ret; +} + +Sema::DeclTy *Sema::ActOnMethodDeclaration( + SourceLocation MethodLoc, SourceLocation EndLoc, + tok::TokenKind MethodType, DeclTy *ClassDecl, + ObjcDeclSpec &ReturnQT, TypeTy *ReturnType, + Selector Sel, + // optional arguments. The number of types/arguments is obtained + // from the Sel.getNumArgs(). + ObjcDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames, + AttributeList *AttrList, tok::ObjCKeywordKind MethodDeclKind, + bool isVariadic) { + llvm::SmallVector Params; + + for (unsigned i = 0; i < Sel.getNumArgs(); i++) { + // FIXME: arg->AttrList must be stored too! + QualType argType; + + if (ArgTypes[i]) + argType = QualType::getFromOpaquePtr(ArgTypes[i]); + else + argType = Context.getObjcIdType(); + ParmVarDecl* Param = new ParmVarDecl(SourceLocation(/*FIXME*/), ArgNames[i], + argType, VarDecl::None, 0); + Param->setObjcDeclQualifier( + CvtQTToAstBitMask(ArgQT[i].getObjcDeclQualifier())); + Params.push_back(Param); + } + QualType resultDeclType; + + if (ReturnType) + resultDeclType = QualType::getFromOpaquePtr(ReturnType); + else // get the type for "id". + resultDeclType = Context.getObjcIdType(); + + Decl *CDecl = static_cast(ClassDecl); + ObjcMethodDecl* ObjcMethod = new ObjcMethodDecl(MethodLoc, EndLoc, Sel, + resultDeclType, + CDecl, + 0, -1, AttrList, + MethodType == tok::minus, isVariadic, + MethodDeclKind == tok::objc_optional ? + ObjcMethodDecl::Optional : + ObjcMethodDecl::Required); + ObjcMethod->setMethodParams(&Params[0], Sel.getNumArgs()); + ObjcMethod->setObjcDeclQualifier( + CvtQTToAstBitMask(ReturnQT.getObjcDeclQualifier())); + const ObjcMethodDecl *PrevMethod = 0; + + // For implementations (which can be very "coarse grain"), we add the + // method now. This allows the AST to implement lookup methods that work + // incrementally (without waiting until we parse the @end). It also allows + // us to flag multiple declaration errors as they occur. + if (ObjcImplementationDecl *ImpDecl = + dyn_cast(CDecl)) { + if (MethodType == tok::minus) { + PrevMethod = ImpDecl->lookupInstanceMethod(Sel); + ImpDecl->addInstanceMethod(ObjcMethod); + } else { + PrevMethod = ImpDecl->lookupClassMethod(Sel); + ImpDecl->addClassMethod(ObjcMethod); + } + } + else if (ObjcCategoryImplDecl *CatImpDecl = + dyn_cast(CDecl)) { + if (MethodType == tok::minus) { + PrevMethod = CatImpDecl->lookupInstanceMethod(Sel); + CatImpDecl->addInstanceMethod(ObjcMethod); + } else { + PrevMethod = CatImpDecl->lookupClassMethod(Sel); + CatImpDecl->addClassMethod(ObjcMethod); + } + } + if (PrevMethod) { + // You can never have two method definitions with the same name. + Diag(ObjcMethod->getLocation(), diag::error_duplicate_method_decl, + ObjcMethod->getSelector().getName()); + Diag(PrevMethod->getLocation(), diag::err_previous_declaration); + } + return ObjcMethod; +} + +Sema::DeclTy *Sema::ActOnAddObjcProperties(SourceLocation AtLoc, + DeclTy **allProperties, unsigned NumProperties, ObjcDeclSpec &DS) { + ObjcPropertyDecl *PDecl = new ObjcPropertyDecl(AtLoc); + + if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_readonly) + PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_readonly); + + if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_getter) { + PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_getter); + PDecl->setGetterName(DS.getGetterName()); + } + + if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_setter) { + PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_setter); + PDecl->setSetterName(DS.getSetterName()); + } + + if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_assign) + PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_assign); + + if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_readwrite) + PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_readwrite); + + if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_retain) + PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_retain); + + if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_copy) + PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_copy); + + if(DS.getPropertyAttributes() & ObjcDeclSpec::DQ_PR_nonatomic) + PDecl->setPropertyAttributes(ObjcPropertyDecl::OBJC_PR_nonatomic); + + PDecl->setNumPropertyDecls(NumProperties); + if (NumProperties != 0) { + ObjcIvarDecl **properties = new ObjcIvarDecl*[NumProperties]; + memcpy(properties, allProperties, NumProperties*sizeof(ObjcIvarDecl*)); + PDecl->setPropertyDecls(properties); + } + return PDecl; +} + Modified: cfe/trunk/clang.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=44925&r1=44924&r2=44925&view=diff ============================================================================== --- cfe/trunk/clang.xcodeproj/project.pbxproj (original) +++ cfe/trunk/clang.xcodeproj/project.pbxproj Wed Dec 12 01:09:47 2007 @@ -82,6 +82,7 @@ DE67E7280C02109800F66BC5 /* ASTStreamer.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE67E7270C02109800F66BC5 /* ASTStreamer.h */; }; DE6951C70C4D1F5D00A5826B /* RecordLayout.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE6951C60C4D1F5D00A5826B /* RecordLayout.h */; }; DE6954640C5121BD00A5826B /* Token.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE6954630C5121BD00A5826B /* Token.h */; }; + DE704B260D0FBEBE009C7762 /* SemaDeclObjC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE704B250D0FBEBE009C7762 /* SemaDeclObjC.cpp */; }; DE75ED290B044DC90020CF81 /* ASTContext.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE75ED280B044DC90020CF81 /* ASTContext.h */; }; DE75EDF10B06880E0020CF81 /* Type.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE75EDF00B06880E0020CF81 /* Type.cpp */; }; DE928B130C05659200231DA4 /* ModuleBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE928B120C05659200231DA4 /* ModuleBuilder.cpp */; }; @@ -312,6 +313,7 @@ DE67E7270C02109800F66BC5 /* ASTStreamer.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTStreamer.h; path = clang/Sema/ASTStreamer.h; sourceTree = ""; }; DE6951C60C4D1F5D00A5826B /* RecordLayout.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = RecordLayout.h; path = clang/AST/RecordLayout.h; sourceTree = ""; }; DE6954630C5121BD00A5826B /* Token.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Token.h; sourceTree = ""; }; + DE704B250D0FBEBE009C7762 /* SemaDeclObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SemaDeclObjC.cpp; path = Sema/SemaDeclObjC.cpp; sourceTree = ""; }; DE75ED280B044DC90020CF81 /* ASTContext.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTContext.h; path = clang/AST/ASTContext.h; sourceTree = ""; }; DE75EDF00B06880E0020CF81 /* Type.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = Type.cpp; path = AST/Type.cpp; sourceTree = ""; }; DE928B120C05659200231DA4 /* ModuleBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ModuleBuilder.cpp; path = CodeGen/ModuleBuilder.cpp; sourceTree = ""; }; @@ -523,6 +525,7 @@ DE67E7160C020EE400F66BC5 /* Sema.cpp */, DEF2F00F0C6CFED5000C4259 /* SemaChecking.cpp */, DE67E7120C020ED900F66BC5 /* SemaDecl.cpp */, + DE704B250D0FBEBE009C7762 /* SemaDeclObjC.cpp */, DE67E7100C020ED400F66BC5 /* SemaExpr.cpp */, DE67E70E0C020ECF00F66BC5 /* SemaExprCXX.cpp */, DE67E70C0C020ECA00F66BC5 /* SemaStmt.cpp */, @@ -867,6 +870,7 @@ 35839B0C0CDF845F006ED061 /* TypeSerialization.cpp in Sources */, 3580CC0C0D072E5C00C5E4F4 /* LangOptions.cpp in Sources */, 353612DA0D075174002E3541 /* TranslationUnit.cpp in Sources */, + DE704B260D0FBEBE009C7762 /* SemaDeclObjC.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From clattner at apple.com Wed Dec 12 01:15:08 2007 From: clattner at apple.com (Chris Lattner) Date: Tue, 11 Dec 2007 23:15:08 -0800 Subject: [cfe-commits] r43948 - in /cfe/trunk: Sema/SemaDecl.cpp Sema/SemaType.cpp test/Sema/method-encoding-2.m In-Reply-To: <200711091718.lA9HIVgW002914@zion.cs.uiuc.edu> References: <200711091718.lA9HIVgW002914@zion.cs.uiuc.edu> Message-ID: <2190421E-1A23-4519-A9A0-9BC1205DA4B9@apple.com> On Nov 9, 2007, at 9:18 AM, Fariborz Jahanian wrote: > Author: fjahanian > Date: Fri Nov 9 11:18:29 2007 > New Revision: 43948 > > Insert invisble arguments to method definition header. Hi Fariborz, The code for handling self etc evolved into: void Sema::ObjcActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { ... // Create Decl objects for each parameter, entrring them in the scope for // binding to their use. struct DeclaratorChunk::ParamInfo PI; // Insert the invisible arguments, self and _cmd! PI.Ident = &Context.Idents.get("self"); PI.IdentLoc = SourceLocation(); // synthesized vars have a null location. PI.InvalidType = false; if (MDecl->isInstance()) { QualType selfTy = Context.getObjcInterfaceType(MDecl- >getClassInterface()); selfTy = Context.getPointerType(selfTy); PI.TypeInfo = selfTy.getAsOpaquePtr(); } else PI.TypeInfo = Context.getObjcIdType().getAsOpaquePtr(); CurMethodDecl->setSelfDecl(ActOnParamDeclarator(PI, FnBodyScope)); similarly for _cmd. Questions: 1. Why are these turning into ParamVarDecls? These are not parameters in the source language, they are magic variables. 2. Why are you setting up a declarator chunk and passing stuff through ActOnParamDeclarator? This code is in Sema already, so it seems like this layer of indirection is not needed. -Chris From sabre at nondot.org Wed Dec 12 01:30:06 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 07:30:06 -0000 Subject: [cfe-commits] r44926 - in /cfe/trunk: AST/Decl.cpp include/clang/AST/DeclObjC.h Message-ID: <200712120730.lBC7U6m9015527@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 01:30:05 2007 New Revision: 44926 URL: http://llvm.org/viewvc/llvm-project?rev=44926&view=rev Log: start cleaning up interfaces for objc bits and pieces by switching to an iterator interface. Modified: cfe/trunk/AST/Decl.cpp cfe/trunk/include/clang/AST/DeclObjC.h Modified: cfe/trunk/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=44926&r1=44925&r2=44926&view=diff ============================================================================== --- cfe/trunk/AST/Decl.cpp (original) +++ cfe/trunk/AST/Decl.cpp Wed Dec 12 01:30:05 2007 @@ -406,8 +406,8 @@ return NULL; } -// lookupInstanceMethod - This method returns an instance method by looking in -// the class, it's categories, and it's super classes (using a linear search). +/// lookupInstanceMethod - This method returns an instance method by looking in +/// the class, it's categories, and it's super classes (using a linear search). ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) { ObjcInterfaceDecl* ClassDecl = this; while (ClassDecl != NULL) { @@ -488,24 +488,20 @@ return NULL; } -// lookupInstanceMethod - This method returns an instance method by looking in -// the class implementation. Unlike interfaces, we don't look outside the -// implementation. -ObjcMethodDecl *ObjcImplementationDecl::lookupInstanceMethod(Selector &Sel) { - ObjcMethodDecl *const*methods = getInstanceMethods(); - int methodCount = getNumInstanceMethods(); - for (int i = 0; i < methodCount; ++i) { - if (methods[i]->getSelector() == Sel) { - return methods[i]; - } - } +/// lookupInstanceMethod - This method returns an instance method by looking in +/// the class implementation. Unlike interfaces, we don't look outside the +/// implementation. +ObjcMethodDecl *ObjcImplementationDecl::lookupInstanceMethod(Selector Sel) { + for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); I != E; ++I) + if ((*I)->getSelector() == Sel) + return *I; return NULL; } -// lookupClassMethod - This method returns an instance method by looking in -// the class implementation. Unlike interfaces, we don't look outside the -// implementation. -ObjcMethodDecl *ObjcImplementationDecl::lookupClassMethod(Selector &Sel) { +/// lookupClassMethod - This method returns a class method by looking in +/// the class implementation. Unlike interfaces, we don't look outside the +/// implementation. +ObjcMethodDecl *ObjcImplementationDecl::lookupClassMethod(Selector Sel) { ObjcMethodDecl *const*methods = getClassMethods(); int methodCount = getNumClassMethods(); for (int i = 0; i < methodCount; ++i) { Modified: cfe/trunk/include/clang/AST/DeclObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=44926&r1=44925&r2=44926&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclObjC.h (original) +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 12 01:30:05 2007 @@ -589,12 +589,34 @@ } int getNumClassMethods() const { return ClassMethods.size(); } - ObjcMethodDecl *lookupInstanceMethod(Selector &Sel); - ObjcMethodDecl *lookupClassMethod(Selector &Sel); - ObjcIvarDecl **getImplDeclIVars() const { return Ivars; } int getImplDeclNumIvars() const { return NumIvars; } - + + + typedef llvm::SmallVector::const_iterator + instmeth_iterator; + instmeth_iterator instmeth_begin() const { return InstanceMethods.begin(); } + instmeth_iterator instmeth_end() const { return InstanceMethods.end(); } + + typedef llvm::SmallVector::const_iterator + classmeth_iterator; + classmeth_iterator classmeth_begin() const { return ClassMethods.begin(); } + classmeth_iterator classmeth_end() const { return ClassMethods.end(); } + + /// lookupInstanceMethod - This method returns an instance method by looking + /// in the class implementation. Unlike interfaces, we don't look outside the + /// implementation. + ObjcMethodDecl *lookupInstanceMethod(Selector Sel); + + /// lookupClassMethod - This method returns a class method by looking in + /// the class implementation. Unlike interfaces, we don't look outside the + /// implementation. + ObjcMethodDecl *lookupClassMethod(Selector Sel); + + typedef ObjcIvarDecl * const *ivar_iterator; + ivar_iterator ivar_begin() const { return Ivars; } + ivar_iterator ivar_end() const { return Ivars+NumIvars; } + static bool classof(const Decl *D) { return D->getKind() == ObjcImplementation; } From sabre at nondot.org Wed Dec 12 01:46:12 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 07:46:12 -0000 Subject: [cfe-commits] r44927 - in /cfe/trunk: AST/Decl.cpp Driver/ASTConsumers.cpp Driver/RewriteTest.cpp include/clang/AST/DeclObjC.h Message-ID: <200712120746.lBC7kDaC016236@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 01:46:12 2007 New Revision: 44927 URL: http://llvm.org/viewvc/llvm-project?rev=44927&view=rev Log: resolve some fixmes and clean up some code by eliminating the get*Vars apis to some classes and use iterators instead. Modified: cfe/trunk/AST/Decl.cpp cfe/trunk/Driver/ASTConsumers.cpp cfe/trunk/Driver/RewriteTest.cpp cfe/trunk/include/clang/AST/DeclObjC.h Modified: cfe/trunk/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=44927&r1=44926&r2=44927&view=diff ============================================================================== --- cfe/trunk/AST/Decl.cpp (original) +++ cfe/trunk/AST/Decl.cpp Wed Dec 12 01:46:12 2007 @@ -502,13 +502,10 @@ /// the class implementation. Unlike interfaces, we don't look outside the /// implementation. ObjcMethodDecl *ObjcImplementationDecl::lookupClassMethod(Selector Sel) { - ObjcMethodDecl *const*methods = getClassMethods(); - int methodCount = getNumClassMethods(); - for (int i = 0; i < methodCount; ++i) { - if (methods[i]->getSelector() == Sel) { - return methods[i]; - } - } + for (classmeth_iterator I = classmeth_begin(), E = classmeth_end(); + I != E; ++I) + if ((*I)->getSelector() == Sel) + return *I; return NULL; } @@ -516,13 +513,9 @@ // the class implementation. Unlike interfaces, we don't look outside the // implementation. ObjcMethodDecl *ObjcCategoryImplDecl::lookupInstanceMethod(Selector &Sel) { - ObjcMethodDecl *const*methods = getInstanceMethods(); - int methodCount = getNumInstanceMethods(); - for (int i = 0; i < methodCount; ++i) { - if (methods[i]->getSelector() == Sel) { - return methods[i]; - } - } + for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); I != E; ++I) + if ((*I)->getSelector() == Sel) + return *I; return NULL; } @@ -530,13 +523,10 @@ // the class implementation. Unlike interfaces, we don't look outside the // implementation. ObjcMethodDecl *ObjcCategoryImplDecl::lookupClassMethod(Selector &Sel) { - ObjcMethodDecl *const*methods = getClassMethods(); - int methodCount = getNumClassMethods(); - for (int i = 0; i < methodCount; ++i) { - if (methods[i]->getSelector() == Sel) { - return methods[i]; - } - } + for (classmeth_iterator I = classmeth_begin(), E = classmeth_end(); + I != E; ++I) + if ((*I)->getSelector() == Sel) + return *I; return NULL; } Modified: cfe/trunk/Driver/ASTConsumers.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=44927&r1=44926&r2=44927&view=diff ============================================================================== --- cfe/trunk/Driver/ASTConsumers.cpp (original) +++ cfe/trunk/Driver/ASTConsumers.cpp Wed Dec 12 01:46:12 2007 @@ -123,9 +123,10 @@ else Out << "@implementation " << I; - for (int i = 0; i < OID->getNumInstanceMethods(); i++) { - PrintObjcMethodDecl(OID->getInstanceMethods()[i]); - ObjcMethodDecl *OMD = OID->getInstanceMethods()[i]; + for (ObjcImplementationDecl::instmeth_iterator I = OID->instmeth_begin(), + E = OID->instmeth_end(); I != E; ++I) { + ObjcMethodDecl *OMD = *I; + PrintObjcMethodDecl(OMD); if (OMD->getBody()) { Out << ' '; OMD->getBody()->printPretty(Out); @@ -133,9 +134,10 @@ } } - for (int i = 0; i < OID->getNumClassMethods(); i++) { - PrintObjcMethodDecl(OID->getClassMethods()[i]); - ObjcMethodDecl *OMD = OID->getClassMethods()[i]; + for (ObjcImplementationDecl::classmeth_iterator I = OID->classmeth_begin(), + E = OID->classmeth_end(); I != E; ++I) { + ObjcMethodDecl *OMD = *I; + PrintObjcMethodDecl(OMD); if (OMD->getBody()) { Out << ' '; OMD->getBody()->printPretty(Out); Modified: cfe/trunk/Driver/RewriteTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44927&r1=44926&r2=44927&view=diff ============================================================================== --- cfe/trunk/Driver/RewriteTest.cpp (original) +++ cfe/trunk/Driver/RewriteTest.cpp Wed Dec 12 01:46:12 2007 @@ -184,8 +184,9 @@ void RewriteObjcCategoryImplDecl(ObjcCategoryImplDecl *CDecl, std::string &Result); - void RewriteObjcMethodsMetaData(ObjcMethodDecl *const*Methods, - int NumMethods, + typedef ObjcCategoryImplDecl::instmeth_iterator instmeth_iterator; + void RewriteObjcMethodsMetaData(instmeth_iterator MethodBegin, + instmeth_iterator MethodEnd, bool IsInstanceMethod, const char *prefix, const char *ClassName, @@ -560,16 +561,11 @@ else Rewrite.InsertText(CID->getLocStart(), "// ", 3); - int numMethods = IMD ? IMD->getNumInstanceMethods() - : CID->getNumInstanceMethods(); - - for (int i = 0; i < numMethods; i++) { + for (ObjcCategoryImplDecl::instmeth_iterator + I = IMD ? IMD->instmeth_begin() : CID->instmeth_begin(), + E = IMD ? IMD->instmeth_end() : CID->instmeth_end(); I != E; ++I) { std::string ResultStr; - ObjcMethodDecl *OMD; - if (IMD) - OMD = IMD->getInstanceMethods()[i]; - else - OMD = CID->getInstanceMethods()[i]; + ObjcMethodDecl *OMD = *I; RewriteObjcMethodDecl(OMD, ResultStr); SourceLocation LocStart = OMD->getLocStart(); SourceLocation LocEnd = OMD->getBody()->getLocStart(); @@ -580,14 +576,11 @@ ResultStr.c_str(), ResultStr.size()); } - numMethods = IMD ? IMD->getNumClassMethods() : CID->getNumClassMethods(); - for (int i = 0; i < numMethods; i++) { + for (ObjcCategoryImplDecl::classmeth_iterator + I = IMD ? IMD->classmeth_begin() : CID->classmeth_begin(), + E = IMD ? IMD->classmeth_end() : CID->classmeth_end(); I != E; ++I) { std::string ResultStr; - ObjcMethodDecl *OMD; - if (IMD) - OMD = IMD->getClassMethods()[i]; - else - OMD = CID->getClassMethods()[i]; + ObjcMethodDecl *OMD = *I; RewriteObjcMethodDecl(OMD, ResultStr); SourceLocation LocStart = OMD->getLocStart(); SourceLocation LocEnd = OMD->getBody()->getLocStart(); @@ -1747,14 +1740,16 @@ // RewriteObjcMethodsMetaData - Rewrite methods metadata for instance or /// class methods. -void RewriteTest::RewriteObjcMethodsMetaData(ObjcMethodDecl *const*Methods, - int NumMethods, +void RewriteTest::RewriteObjcMethodsMetaData(instmeth_iterator MethodBegin, + instmeth_iterator MethodEnd, bool IsInstanceMethod, const char *prefix, const char *ClassName, std::string &Result) { + if (MethodBegin == MethodEnd) return; + static bool objc_impl_method = false; - if (NumMethods > 0 && !objc_impl_method) { + if (!objc_impl_method) { /* struct _objc_method { SEL _cmd; char *method_types; @@ -1779,40 +1774,39 @@ Result += "\tstruct _objc_method method_list[];\n};\n"; objc_impl_method = true; } + // Build _objc_method_list for class's methods if needed - if (NumMethods > 0) { - Result += "\nstatic struct _objc_method_list _OBJC_"; - Result += prefix; - Result += IsInstanceMethod ? "INSTANCE" : "CLASS"; - Result += "_METHODS_"; - Result += ClassName; - Result += " __attribute__ ((section (\"__OBJC, __"; - Result += IsInstanceMethod ? "inst" : "cls"; - Result += "_meth\")))= "; - Result += "{\n\t0, " + utostr(NumMethods) + "\n"; - - Result += "\t,{{(SEL)\""; - Result += Methods[0]->getSelector().getName().c_str(); + Result += "\nstatic struct _objc_method_list _OBJC_"; + Result += prefix; + Result += IsInstanceMethod ? "INSTANCE" : "CLASS"; + Result += "_METHODS_"; + Result += ClassName; + Result += " __attribute__ ((section (\"__OBJC, __"; + Result += IsInstanceMethod ? "inst" : "cls"; + Result += "_meth\")))= "; + Result += "{\n\t0, " + utostr(MethodEnd-MethodBegin) + "\n"; + + Result += "\t,{{(SEL)\""; + Result += (*MethodBegin)->getSelector().getName().c_str(); + std::string MethodTypeString; + Context->getObjcEncodingForMethodDecl(*MethodBegin, MethodTypeString); + Result += "\", \""; + Result += MethodTypeString; + Result += "\", "; + Result += MethodInternalNames[*MethodBegin]; + Result += "}\n"; + for (++MethodBegin; MethodBegin != MethodEnd; ++MethodBegin) { + Result += "\t ,{(SEL)\""; + Result += (*MethodBegin)->getSelector().getName().c_str(); std::string MethodTypeString; - Context->getObjcEncodingForMethodDecl(Methods[0], MethodTypeString); + Context->getObjcEncodingForMethodDecl(*MethodBegin, MethodTypeString); Result += "\", \""; Result += MethodTypeString; Result += "\", "; - Result += MethodInternalNames[Methods[0]]; + Result += MethodInternalNames[*MethodBegin]; Result += "}\n"; - for (int i = 1; i < NumMethods; i++) { - Result += "\t ,{(SEL)\""; - Result += Methods[i]->getSelector().getName().c_str(); - std::string MethodTypeString; - Context->getObjcEncodingForMethodDecl(Methods[i], MethodTypeString); - Result += "\", \""; - Result += MethodTypeString; - Result += "\", "; - Result += MethodInternalNames[Methods[i]]; - Result += "}\n"; - } - Result += "\t }\n};\n"; } + Result += "\t }\n};\n"; } /// RewriteObjcProtocolsMetaData - Rewrite protocols meta-data. @@ -2000,16 +1994,12 @@ sprintf(FullCategoryName, "%s_%s", ClassDecl->getName(), IDecl->getName()); // Build _objc_method_list for class's instance methods if needed - RewriteObjcMethodsMetaData(IDecl->getInstanceMethods(), - IDecl->getNumInstanceMethods(), - true, - "CATEGORY_", FullCategoryName, Result); + RewriteObjcMethodsMetaData(IDecl->instmeth_begin(), IDecl->instmeth_end(), + true, "CATEGORY_", FullCategoryName, Result); // Build _objc_method_list for class's class methods if needed - RewriteObjcMethodsMetaData(IDecl->getClassMethods(), - IDecl->getNumClassMethods(), - false, - "CATEGORY_", FullCategoryName, Result); + RewriteObjcMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(), + false, "CATEGORY_", FullCategoryName, Result); // Protocols referenced in class declaration? // Null CDecl is case of a category implementation with no category interface @@ -2172,22 +2162,17 @@ } // Build _objc_method_list for class's instance methods if needed - RewriteObjcMethodsMetaData(IDecl->getInstanceMethods(), - IDecl->getNumInstanceMethods(), - true, - "", IDecl->getName(), Result); + RewriteObjcMethodsMetaData(IDecl->instmeth_begin(), IDecl->instmeth_end(), + true, "", IDecl->getName(), Result); // Build _objc_method_list for class's class methods if needed - RewriteObjcMethodsMetaData(IDecl->getClassMethods(), - IDecl->getNumClassMethods(), - false, - "", IDecl->getName(), Result); + RewriteObjcMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(), + false, "", IDecl->getName(), Result); // Protocols referenced in class declaration? RewriteObjcProtocolsMetaData(CDecl->getReferencedProtocols(), CDecl->getNumIntfRefProtocols(), - "CLASS", - CDecl->getName(), Result); + "CLASS", CDecl->getName(), Result); // Declaration of class/meta-class metadata Modified: cfe/trunk/include/clang/AST/DeclObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=44927&r1=44926&r2=44927&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclObjC.h (original) +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 12 01:46:12 2007 @@ -155,8 +155,7 @@ // We also need to record the @end location. SourceLocation getAtEndLoc() const { return AtEndLoc; } - const int getNumPropertyDecl() const { return NumPropertyDecl; } - int getNumPropertyDecl() { return NumPropertyDecl; } + int getNumPropertyDecl() const { return NumPropertyDecl; } void setNumPropertyDecl(int num) { NumPropertyDecl = num; } ObjcPropertyDecl **const getPropertyDecl() const { return PropertyDecl; } @@ -479,24 +478,14 @@ SourceLocation EndLoc; public: - ObjcCategoryImplDecl(SourceLocation L, IdentifierInfo *Id, - ObjcInterfaceDecl *classInterface) - : NamedDecl(ObjcCategoryImpl, L, Id), - ClassInterface(classInterface) {} + ObjcCategoryImplDecl(SourceLocation L, IdentifierInfo *Id, + ObjcInterfaceDecl *classInterface) + : NamedDecl(ObjcCategoryImpl, L, Id), ClassInterface(classInterface) {} ObjcInterfaceDecl *getClassInterface() const { return ClassInterface; } - // FIXME: Figure out how to remove the const pointer below. - ObjcMethodDecl *const*getInstanceMethods() const { - return &InstanceMethods[0]; - } - int getNumInstanceMethods() const { return InstanceMethods.size(); } - - // FIXME: Figure out how to remove the const pointer below. - ObjcMethodDecl *const*getClassMethods() const { - return &ClassMethods[0]; - } - int getNumClassMethods() const { return ClassMethods.size(); } + unsigned getNumInstanceMethods() const { return InstanceMethods.size(); } + unsigned getNumClassMethods() const { return ClassMethods.size(); } void addInstanceMethod(ObjcMethodDecl *method) { InstanceMethods.push_back(method); @@ -507,6 +496,17 @@ ObjcMethodDecl *lookupInstanceMethod(Selector &Sel); ObjcMethodDecl *lookupClassMethod(Selector &Sel); + typedef llvm::SmallVector::const_iterator + instmeth_iterator; + instmeth_iterator instmeth_begin() const { return InstanceMethods.begin(); } + instmeth_iterator instmeth_end() const { return InstanceMethods.end(); } + + typedef llvm::SmallVector::const_iterator + classmeth_iterator; + classmeth_iterator classmeth_begin() const { return ClassMethods.begin(); } + classmeth_iterator classmeth_end() const { return ClassMethods.end(); } + + // Location information, modeled after the Stmt API. SourceLocation getLocStart() const { return getLocation(); } SourceLocation getLocEnd() const { return EndLoc; } @@ -577,20 +577,11 @@ void setSuperClass(ObjcInterfaceDecl * superCls) { SuperClass = superCls; } - // FIXME: Figure out how to remove the const pointer below. - ObjcMethodDecl *const*getInstanceMethods() const { - return &InstanceMethods[0]; - } - int getNumInstanceMethods() const { return InstanceMethods.size(); } - - // FIXME: Figure out how to remove the const pointer below. - ObjcMethodDecl *const*getClassMethods() const { - return &ClassMethods[0]; - } - int getNumClassMethods() const { return ClassMethods.size(); } + unsigned getNumInstanceMethods() const { return InstanceMethods.size(); } + unsigned getNumClassMethods() const { return ClassMethods.size(); } ObjcIvarDecl **getImplDeclIVars() const { return Ivars; } - int getImplDeclNumIvars() const { return NumIvars; } + unsigned getImplDeclNumIvars() const { return NumIvars; } typedef llvm::SmallVector::const_iterator From sabre at nondot.org Wed Dec 12 01:56:43 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 07:56:43 -0000 Subject: [cfe-commits] r44930 - in /cfe/trunk: AST/Decl.cpp Driver/ASTConsumers.cpp Driver/RewriteTest.cpp include/clang/AST/DeclObjC.h Message-ID: <200712120756.lBC7uhQ0016732@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 01:56:42 2007 New Revision: 44930 URL: http://llvm.org/viewvc/llvm-project?rev=44930&view=rev Log: more cleanups changing things like getInstanceVariables to iterators. Modified: cfe/trunk/AST/Decl.cpp cfe/trunk/Driver/ASTConsumers.cpp cfe/trunk/Driver/RewriteTest.cpp cfe/trunk/include/clang/AST/DeclObjC.h Modified: cfe/trunk/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=44930&r1=44929&r2=44930&view=diff ============================================================================== --- cfe/trunk/AST/Decl.cpp (original) +++ cfe/trunk/AST/Decl.cpp Wed Dec 12 01:56:42 2007 @@ -393,12 +393,11 @@ IdentifierInfo *ID, ObjcInterfaceDecl *&clsDeclared) { ObjcInterfaceDecl* ClassDecl = this; while (ClassDecl != NULL) { - ObjcIvarDecl **ivars = ClassDecl->getInstanceVariables(); - int ivarCount = ClassDecl->getNumInstanceVariables(); - for (int i = 0; i < ivarCount; ++i) { - if (ivars[i]->getIdentifier() == ID) { + for (ivar_iterator I = ClassDecl->ivar_begin(), E = ClassDecl->ivar_end(); + I != E; ++I) { + if ((*I)->getIdentifier() == ID) { clsDeclared = ClassDecl; - return ivars[i]; + return *I; } } ClassDecl = ClassDecl->getSuperClass(); Modified: cfe/trunk/Driver/ASTConsumers.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=44930&r1=44929&r2=44930&view=diff ============================================================================== --- cfe/trunk/Driver/ASTConsumers.cpp (original) +++ cfe/trunk/Driver/ASTConsumers.cpp Wed Dec 12 01:56:42 2007 @@ -172,14 +172,12 @@ else Out << '\n'; - int NumIvars = OID->getNumInstanceVariables(); - if (NumIvars > 0) { - ObjcIvarDecl **Ivars = OID->getInstanceVariables(); + if (OID->getNumInstanceVariables() > 0) { Out << '{'; - for (int i = 0; i < NumIvars; i++) { - Out << '\t' << Ivars[i]->getType().getAsString() - << ' ' << Ivars[i]->getName() - << ";\n"; + for (ObjcInterfaceDecl::ivar_iterator I = OID->ivar_begin(), + E = OID->ivar_end(); I != E; ++I) { + Out << '\t' << (*I)->getType().getAsString() + << ' ' << (*I)->getName() << ";\n"; } Out << "}\n"; } Modified: cfe/trunk/Driver/RewriteTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44930&r1=44929&r2=44930&view=diff ============================================================================== --- cfe/trunk/Driver/RewriteTest.cpp (original) +++ cfe/trunk/Driver/RewriteTest.cpp Wed Dec 12 01:56:42 2007 @@ -2090,10 +2090,6 @@ std::string &Result) { ObjcInterfaceDecl *CDecl = IDecl->getClassInterface(); - // Build _objc_ivar_list metadata for classes ivars if needed - int NumIvars = IDecl->getImplDeclNumIvars() > 0 - ? IDecl->getImplDeclNumIvars() - : (CDecl ? CDecl->getNumInstanceVariables() : 0); // Explictly declared @interface's are already synthesized. if (CDecl->ImplicitInterfaceDecl()) { // FIXME: Implementation of a class with no @interface (legacy) doese not @@ -2101,6 +2097,10 @@ SynthesizeObjcInternalStruct(CDecl, Result); } + // Build _objc_ivar_list metadata for classes ivars if needed + int NumIvars = IDecl->getImplDeclNumIvars() > 0 + ? IDecl->getImplDeclNumIvars() + : (CDecl ? CDecl->getNumInstanceVariables() : 0); if (NumIvars > 0) { static bool objc_ivar = false; if (!objc_ivar) { @@ -2133,28 +2133,33 @@ "{\n\t"; Result += utostr(NumIvars); Result += "\n"; - - ObjcIvarDecl **Ivars = IDecl->getImplDeclIVars() - ? IDecl->getImplDeclIVars() - : CDecl->getInstanceVariables(); + + ObjcInterfaceDecl::ivar_iterator IVI, IVE; + if (IDecl->getImplDeclNumIvars() > 0) { + IVI = IDecl->ivar_begin(); + IVE = IDecl->ivar_end(); + } else { + IVI = CDecl->ivar_begin(); + IVE = CDecl->ivar_end(); + } Result += "\t,{{\""; - Result += Ivars[0]->getName(); + Result += (*IVI)->getName(); Result += "\", \""; std::string StrEncoding; - Context->getObjcEncodingForType(Ivars[0]->getType(), StrEncoding); + Context->getObjcEncodingForType((*IVI)->getType(), StrEncoding); Result += StrEncoding; Result += "\", "; - SynthesizeIvarOffsetComputation(IDecl, Ivars[0], Result); + SynthesizeIvarOffsetComputation(IDecl, *IVI, Result); Result += "}\n"; - for (int i = 1; i < NumIvars; i++) { + for (++IVI; IVI != IVE; ++IVI) { Result += "\t ,{\""; - Result += Ivars[i]->getName(); + Result += (*IVI)->getName(); Result += "\", \""; std::string StrEncoding; - Context->getObjcEncodingForType(Ivars[i]->getType(), StrEncoding); + Context->getObjcEncodingForType((*IVI)->getType(), StrEncoding); Result += StrEncoding; Result += "\", "; - SynthesizeIvarOffsetComputation(IDecl, Ivars[i], Result); + SynthesizeIvarOffsetComputation(IDecl, (*IVI), Result); Result += "}\n"; } Modified: cfe/trunk/include/clang/AST/DeclObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=44930&r1=44929&r2=44930&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclObjC.h (original) +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 12 01:56:42 2007 @@ -111,9 +111,12 @@ } int getNumIntfRefProtocols() const { return NumReferencedProtocols; } - ObjcIvarDecl **getInstanceVariables() const { return Ivars; } int getNumInstanceVariables() const { return NumIvars; } + typedef ObjcIvarDecl * const *ivar_iterator; + ivar_iterator ivar_begin() const { return Ivars; } + ivar_iterator ivar_end() const { return Ivars+(NumIvars == -1 ?0 : NumIvars);} + ObjcMethodDecl** getInstanceMethods() const { return InstanceMethods; } int getNumInstanceMethods() const { return NumInstanceMethods; } @@ -580,7 +583,6 @@ unsigned getNumInstanceMethods() const { return InstanceMethods.size(); } unsigned getNumClassMethods() const { return ClassMethods.size(); } - ObjcIvarDecl **getImplDeclIVars() const { return Ivars; } unsigned getImplDeclNumIvars() const { return NumIvars; } From clattner at apple.com Wed Dec 12 02:15:48 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 00:15:48 -0800 Subject: [cfe-commits] r43989 - in /cfe/trunk: AST/Decl.cpp Sema/Sema.h Sema/SemaDecl.cpp Sema/SemaExpr.cpp include/clang/AST/DeclObjC.h test/Sema/message.m In-Reply-To: <200711110010.lAB0AmpG018214@zion.cs.uiuc.edu> References: <200711110010.lAB0AmpG018214@zion.cs.uiuc.edu> Message-ID: <73CC5ED6-31CD-4446-B39E-A4629C7F5F58@apple.com> On Nov 10, 2007, at 4:10 PM, Steve Naroff wrote: > Author: snaroff > Date: Sat Nov 10 18:10:47 2007 > New Revision: 43989 > > URL: http://llvm.org/viewvc/llvm-project?rev=43989&view=rev > Log: > > Teach Sema::ActOnInstanceMessage() about private methods. That is, > methods declared in an implementation (but not listed in the > interface). > > +// lookupInstanceMethod - This method returns an instance method by > looking in > +// the class implementation. Unlike interfaces, we don't look > outside the > +// implementation. > +ObjcMethodDecl > *ObjcImplementationDecl::lookupInstanceMethod(Selector &Sel) { > + ObjcMethodDecl **methods = getInstanceMethods(); > + int methodCount = getNumInstanceMethods(); > + for (int i = 0; i < methodCount; ++i) { > + if (methods[i]->getSelector() == Sel) { > + return methods[i]; > + } > + } > + return NULL; > +} Hi Steve, I started making some changes related to this, but I need your help. Please make the following changes: 1. Introduce iterators for all of the "accessors" for the various lists in the ObjC data structures. For example ObjcInterfaceDecl::getInstanceMethods should go away. This is important because the type returned by getInstanceMethods is currently incorrect (even though the method is const, the returned pointer is not correctly const qualified). 2. Switch clients over from using stuff like getInstanceMethods to use the iterators and remove the old interfaces. The various objc class should not expose to their clients that how they happen to represent these lists. 3. There are inconsistencies in the ObjC class interfaces. For example, it is ObjcInterfaceDecl::getNumInstanceVariables but it is ObjcImplementationDecl::getImplDeclNumIvars. This is strangeness. Please pick a set of shorthand (e.g. Inst for instance, Proto for protocol, Meth for method, Vars for variables etc) and use it consistently. Many method names are really long. getNumInstanceVariables should get getNumInstVars() or getNumIVars(). 4. There are 4 or 5 implementations of lookupInstanceMethod, and they all do different things. :( Please pick a name that is more specific to the various classes that explains how it searches. For example, ObjcImplementationDecl::lookupInstanceMethod could be ObjcImplementationDecl::findDefinedInstMethod(), which makes it more clear that it only returns things *defined in the @implementation*. 5. Related, I think you should split ObjcProtocolDecl::lookupInstanceMethod up into two things: one that searches locally, and one that walks the "referenced protocols", calling the local search on each one. Likewise for any similar ones. 6. One specific question is that ObjcInterfaceDecl::lookupInstanceMethod scans methods immediately referenced in protocols, but it doesn't scan protocol's parent protocols. Is this correct? Either way, please change it to call the methods added in step #5. 7. We need documentation on methods like ObjcInterfaceDecl::addMethods that explicitly say that they don't take ownership of the pointers passed in. 8. This is a very common pattern in the ObjC classes: ... Class ... /// category instance methods ObjcMethodDecl **InstanceMethods; // Null if not defined int NumInstanceMethods; // -1 if not defined ... ... header exposes iterator interface... NumInstanceMethods = numInsMembers; if (numInsMembers) { InstanceMethods = new ObjcMethodDecl*[numInsMembers]; memcpy(InstanceMethods, insMethods, numInsMembers*sizeof(ObjcMethodDecl*)); } I don't like how the clients are expected to check for null/-1 to use this API. I think that it should just expose an iterator interface, which will give an empty range instead of null/-1. The client would be forced to check something else to distinguish between an interface forward def and and interface definition with no inst methods. Given that change, I think it may make sense to introduce a new simple class that wraps this concept. This would give us: MyDynamicArray InstMethods; instead of the two fields above. This is a lot of stuff, but it can be done one at a time. I think it's really important to get the APIs right before there are more clients. Please lemme know if you disagree with any of the above of course, -Chris From sabre at nondot.org Wed Dec 12 02:17:51 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 08:17:51 -0000 Subject: [cfe-commits] r44932 - /cfe/trunk/AST/Decl.cpp Message-ID: <200712120817.lBC8Hp0d018134@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 02:17:45 2007 New Revision: 44932 URL: http://llvm.org/viewvc/llvm-project?rev=44932&view=rev Log: fix typo Modified: cfe/trunk/AST/Decl.cpp Modified: cfe/trunk/AST/Decl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=44932&r1=44931&r2=44932&view=diff ============================================================================== --- cfe/trunk/AST/Decl.cpp (original) +++ cfe/trunk/AST/Decl.cpp Wed Dec 12 02:17:45 2007 @@ -406,7 +406,7 @@ } /// lookupInstanceMethod - This method returns an instance method by looking in -/// the class, it's categories, and it's super classes (using a linear search). +/// the class, its categories, and its super classes (using a linear search). ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) { ObjcInterfaceDecl* ClassDecl = this; while (ClassDecl != NULL) { @@ -447,7 +447,7 @@ } // lookupClassMethod - This method returns a class method by looking in the -// class, it's categories, and it's super classes (using a linear search). +// class, its categories, and its super classes (using a linear search). ObjcMethodDecl *ObjcInterfaceDecl::lookupClassMethod(Selector &Sel) { ObjcInterfaceDecl* ClassDecl = this; while (ClassDecl != NULL) { From snaroff at apple.com Wed Dec 12 09:06:26 2007 From: snaroff at apple.com (Steve Naroff) Date: Wed, 12 Dec 2007 07:06:26 -0800 Subject: [cfe-commits] r43989 - in /cfe/trunk: AST/Decl.cpp Sema/Sema.h Sema/SemaDecl.cpp Sema/SemaExpr.cpp include/clang/AST/DeclObjC.h test/Sema/message.m In-Reply-To: <73CC5ED6-31CD-4446-B39E-A4629C7F5F58@apple.com> References: <200711110010.lAB0AmpG018214@zion.cs.uiuc.edu> <73CC5ED6-31CD-4446-B39E-A4629C7F5F58@apple.com> Message-ID: <7CB5AA87-F214-43E1-B4D3-F66B9618D7BC@apple.com> On Dec 12, 2007, at 12:15 AM, Chris Lattner wrote: > On Nov 10, 2007, at 4:10 PM, Steve Naroff wrote: >> Author: snaroff >> Date: Sat Nov 10 18:10:47 2007 >> New Revision: 43989 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=43989&view=rev >> Log: >> >> Teach Sema::ActOnInstanceMessage() about private methods. That is, >> methods declared in an implementation (but not listed in the >> interface). >> >> +// lookupInstanceMethod - This method returns an instance method >> by looking in >> +// the class implementation. Unlike interfaces, we don't look >> outside the >> +// implementation. >> +ObjcMethodDecl >> *ObjcImplementationDecl::lookupInstanceMethod(Selector &Sel) { >> + ObjcMethodDecl **methods = getInstanceMethods(); >> + int methodCount = getNumInstanceMethods(); >> + for (int i = 0; i < methodCount; ++i) { >> + if (methods[i]->getSelector() == Sel) { >> + return methods[i]; >> + } >> + } >> + return NULL; >> +} > > Hi Steve, > > I started making some changes related to this, but I need your help. > > Please make the following changes: > > 1. Introduce iterators for all of the "accessors" for the various > lists in the ObjC data structures. For example > ObjcInterfaceDecl::getInstanceMethods should go away. This is > important because the type returned by getInstanceMethods is > currently incorrect (even though the method is const, the returned > pointer is not correctly const qualified). > 2. Switch clients over from using stuff like getInstanceMethods to > use the iterators and remove the old interfaces. The various objc > class should not expose to their clients that how they happen to > represent these lists. > Absolutely (to items 1/2). > 3. There are inconsistencies in the ObjC class interfaces. For > example, it is ObjcInterfaceDecl::getNumInstanceVariables but it is > ObjcImplementationDecl::getImplDeclNumIvars. This is strangeness. > Please pick a set of shorthand (e.g. Inst for instance, Proto for > protocol, Meth for method, Vars for variables etc) and use it > consistently. Many method names are really long. > getNumInstanceVariables should get getNumInstVars() or getNumIVars(). > I agree with removing the inconsistency. There are two consistency issues here: (1) the ObjC AST API's should be self consistent. (2) the ObjC AST API's should be consistent with the C AST API's. That said, I think shortening the names (and coming up with a bunch of abbreviations) is questionable. For example, the type checker uses "getCanonicalType" all over the place. Here is an excerpt... QualType lhs = lhsExpr- >getType().getCanonicalType().getUnqualifiedType(); QualType rhs = rhsExpr- >getType().getCanonicalType().getUnqualifiedType(); From my perspective, the Type accessors have long names. We could consider converting them to... QualType lhs = lhsExpr->getType().getCanonType().getUnqualType(); QualType rhs = rhsExpr->getType().getCanonType().getUnqualType(); From my perspective, this would be the wrong decision (since the original names are "good"). I general, I don't believe shortening names just for the sake of shortening is the right decision. The names can certainly be improved. I just don't see a general/good solution to your complaint that "Many method names are really long". > 4. There are 4 or 5 implementations of lookupInstanceMethod, and > they all do different things. :( Please pick a name that is more > specific to the various classes that explains how it searches. For > example, ObjcImplementationDecl::lookupInstanceMethod could be > ObjcImplementationDecl::findDefinedInstMethod(), which makes it more > clear that it only returns things *defined in the @implementation*. > I disagree with your assertion that "they all do different things. : (". From my perspective, using polymorphism here makes sense. > 5. Related, I think you should split > ObjcProtocolDecl::lookupInstanceMethod up into two things: one that > searches locally, and one that walks the "referenced protocols", > calling the local search on each one. Likewise for any similar ones. > I think having different ways to search is fine. Off hand, I don't know if I prefer a "knob" (on an existing API) or a new API. To some extent is depends on how we resolve the naming/polymorphism issues above. > 6. One specific question is that > ObjcInterfaceDecl::lookupInstanceMethod scans methods immediately > referenced in protocols, but it doesn't scan protocol's parent > protocols. Is this correct? Either way, please change it to call > the methods added in step #5. > I agree with you...I don't believe this is correct. ObjcInterfaceDecl should likely query the protocol directly (rather than iterate over the protocols instance methods directly). > 7. We need documentation on methods like > ObjcInterfaceDecl::addMethods that explicitly say that they don't > take ownership of the pointers passed in. > o.k. > 8. This is a very common pattern in the ObjC classes: > > ... Class ... > /// category instance methods > ObjcMethodDecl **InstanceMethods; // Null if not defined > int NumInstanceMethods; // -1 if not defined > ... > > ... header exposes iterator interface... > > NumInstanceMethods = numInsMembers; > if (numInsMembers) { > InstanceMethods = new ObjcMethodDecl*[numInsMembers]; > memcpy(InstanceMethods, insMethods, > numInsMembers*sizeof(ObjcMethodDecl*)); > } > > > I don't like how the clients are expected to check for null/-1 to > use this API. I think that it should just expose an iterator > interface, which will give an empty range instead of null/-1. The > client would be forced to check something else to distinguish > between an interface forward def and and interface definition with > no inst methods. > > Given that change, I think it may make sense to introduce a new > simple class that wraps this concept. This would give us: > > MyDynamicArray InstMethods; > > instead of the two fields above. > > > This is a lot of stuff, but it can be done one at a time. I think > it's really important to get the APIs right before there are more > clients. Please lemme know if you disagree with any of the above of > course, > > -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/cfe-commits/attachments/20071212/bf6fbfb5/attachment-0001.html From fjahanian at apple.com Wed Dec 12 10:40:55 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Wed, 12 Dec 2007 08:40:55 -0800 Subject: [cfe-commits] build failure Message-ID: <498AB2AD-B881-48C1-9B1C-FE87FED045D6@apple.com> After update, I am getting: llvm[1]: Compiling SemaDeclObjC.cpp for Debug build SemaDeclObjC.cpp: In member function ?void clang::Sema::CheckImplementationIvars(clang::ObjcImplementationDecl*, clang::ObjcIvarDecl**, unsigned int, clang::SourceLocation)?: SemaDeclObjC.cpp:416: error: ?class clang::ObjcInterfaceDecl? has no member named ?getInstanceVariables? SemaDeclObjC.cpp: In member function ?void clang::Sema::ImplMethodsVsClassMethods(clang::ObjcImplementationDecl*, clang::ObjcInterfaceDecl*)?: SemaDeclObjC.cpp:487: error: ?class clang::ObjcImplementationDecl? has no member named ?getInstanceMethods? SemaDeclObjC.cpp:488: warning: comparison between signed and unsigned integer expressions SemaDeclObjC.cpp:502: error: ?class clang::ObjcImplementationDecl? has no member named ?getClassMethods? SemaDeclObjC.cpp:503: warning: comparison between signed and unsigned integer expressions SemaDeclObjC.cpp: In member function ?void clang ::Sema::ImplCategoryMethodsVsIntfMethods(clang::ObjcCategoryImplDecl*, clang::ObjcCategoryDecl*)?: SemaDeclObjC.cpp:532: error: ?class clang::ObjcCategoryImplDecl? has no member named ?getInstanceMethods? SemaDeclObjC.cpp:533: warning: comparison between signed and unsigned integer expressions SemaDeclObjC.cpp:547: error: ?class clang::ObjcCategoryImplDecl? has no member named ?getClassMethods? SemaDeclObjC.cpp:548: warning: comparison between signed and unsigned integer expressions make[1]: *** [/Volumes/sandbox/llvm/tools/clang/Sema/Debug/ SemaDeclObjC.o] Error 1 From kremenek at apple.com Wed Dec 12 10:55:58 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 08:55:58 -0800 Subject: [cfe-commits] build failure In-Reply-To: <498AB2AD-B881-48C1-9B1C-FE87FED045D6@apple.com> References: <498AB2AD-B881-48C1-9B1C-FE87FED045D6@apple.com> Message-ID: <14B461C4-849F-4C19-900D-C6C474D3ADBF@apple.com> I'm getting this too. On Dec 12, 2007, at 8:40 AM, Fariborz Jahanian wrote: > After update, I am getting: > > llvm[1]: Compiling SemaDeclObjC.cpp for Debug build > SemaDeclObjC.cpp: In member function ?void > clang::Sema::CheckImplementationIvars(clang::ObjcImplementationDecl*, > clang::ObjcIvarDecl**, unsigned int, clang::SourceLocation)?: > SemaDeclObjC.cpp:416: error: ?class clang::ObjcInterfaceDecl? has no > member named ?getInstanceVariables? > SemaDeclObjC.cpp: In member function ?void > clang::Sema::ImplMethodsVsClassMethods(clang::ObjcImplementationDecl*, > clang::ObjcInterfaceDecl*)?: > SemaDeclObjC.cpp:487: error: ?class clang::ObjcImplementationDecl? has > no member named ?getInstanceMethods? > SemaDeclObjC.cpp:488: warning: comparison between signed and unsigned > integer expressions > SemaDeclObjC.cpp:502: error: ?class clang::ObjcImplementationDecl? has > no member named ?getClassMethods? > SemaDeclObjC.cpp:503: warning: comparison between signed and unsigned > integer expressions > SemaDeclObjC.cpp: In member function ?void > clang > ::Sema::ImplCategoryMethodsVsIntfMethods(clang::ObjcCategoryImplDecl*, > clang::ObjcCategoryDecl*)?: > SemaDeclObjC.cpp:532: error: ?class clang::ObjcCategoryImplDecl? has > no member named ?getInstanceMethods? > SemaDeclObjC.cpp:533: warning: comparison between signed and unsigned > integer expressions > SemaDeclObjC.cpp:547: error: ?class clang::ObjcCategoryImplDecl? has > no member named ?getClassMethods? > SemaDeclObjC.cpp:548: warning: comparison between signed and unsigned > integer expressions > make[1]: *** [/Volumes/sandbox/llvm/tools/clang/Sema/Debug/ > SemaDeclObjC.o] Error 1 > > > _______________________________________________ > cfe-commits mailing list > cfe-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits From fjahanian at apple.com Wed Dec 12 11:21:04 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Wed, 12 Dec 2007 09:21:04 -0800 Subject: [cfe-commits] r43534 - in /cfe/trunk: Sema/SemaDecl.cpp clang.xcodeproj/project.pbxproj include/clang/AST/Decl.h include/clang/AST/DeclObjC.h In-Reply-To: <4720021F-6D3C-4039-B289-E4B4BFD916E8@apple.com> References: <200710310012.l9V0CZW6004188@zion.cs.uiuc.edu> <4720021F-6D3C-4039-B289-E4B4BFD916E8@apple.com> Message-ID: <5CCABBBD-0CBF-4C6A-A0F6-1DD4877C7FAE@apple.com> On Dec 11, 2007, at 10:05 PM, Chris Lattner wrote: > On Oct 30, 2007, at 5:12 PM, Fariborz Jahanian wrote: >> Author: fjahanian >> Date: Tue Oct 30 19:12:35 2007 >> New Revision: 43534 >> >> Added new type and bitfield fields in some decl types in >> preparation for objective-c's type qualifiers. >> Added initialization of Class/SEMA types. > > Hi Fariborz, > > This patch adds ObjcDeclQualifier to VarDecl. Doesn't it make more > sense for them to be on ParmVarDecl? Yes it does. I will make the change later today. - Fariborz > > > -Chris > >> + /// ObjcDeclQualifier - Qualifier used on types in method >> declarations >> + /// for remote messaging. They are meant for the arguments >> though and >> + /// applied to the Decls (ObjcMethodDecl and ParmVarDecl). >> + enum ObjcDeclQualifier { >> + OBJC_TQ_None = 0x0, >> + OBJC_TQ_In = 0x1, >> + OBJC_TQ_Inout = 0x2, >> + OBJC_TQ_Out = 0x4, >> + OBJC_TQ_Bycopy = 0x8, >> + OBJC_TQ_Byref = 0x10, >> + OBJC_TQ_Oneway = 0x20 >> + }; >> + >> private: >> /// Loc - The location that this decl. >> SourceLocation Loc; >> @@ -280,6 +293,8 @@ >> // as static variables declared within a function. >> bool hasGlobalStorage() const { return !hasAutoStorage(); } >> >> + ObjcDeclQualifier getObjcDeclQualifier() const { return >> objcDeclQualifier; } >> + >> // Implement isa/cast/dyncast/etc. >> static bool classof(const Decl *D) { >> return D->getKind() >= VarFirst && D->getKind() <= VarLast; >> @@ -288,11 +303,16 @@ >> protected: >> VarDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T, >> StorageClass SC, ScopedDecl *PrevDecl) >> - : ValueDecl(DK, L, Id, T, PrevDecl), Init(0) { SClass = SC; } >> + : ValueDecl(DK, L, Id, T, PrevDecl), Init(0), >> + objcDeclQualifier(OBJC_TQ_None) { SClass = SC; } >> private: >> Expr *Init; >> // FIXME: This can be packed into the bitfields in Decl. >> unsigned SClass : 3; >> + /// FIXME: Also can be paced into the bitfields in Decl. >> + /// in, inout, etc. >> + ObjcDeclQualifier objcDeclQualifier : 6; >> + >> friend class StmtIteratorBase; >> }; >> >> >> Modified: cfe/trunk/include/clang/AST/DeclObjC.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=43534&r1=43533&r2=43534&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- cfe/trunk/include/clang/AST/DeclObjC.h (original) >> +++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Oct 30 19:12:35 2007 >> @@ -218,6 +218,9 @@ >> /// @required/@optional >> ImplementationControl DeclImplementation : 2; >> >> + /// in, inout, etc. >> + ObjcDeclQualifier objcDeclQualifier : 6; >> + >> // A unigue name for this method. >> Selector SelName; >> >> @@ -241,11 +244,14 @@ >> Decl *PrevDecl = 0) >> : Decl(ObjcMethod, beginLoc), >> IsInstance(isInstance), DeclImplementation(impControl), >> + objcDeclQualifier(OBJC_TQ_None), >> SelName(SelInfo), MethodDeclType(T), >> ParamInfo(paramInfo), NumMethodParams(numParams), >> MethodAttrs(M), EndLoc(endLoc) {} >> virtual ~ObjcMethodDecl(); >> >> + ObjcDeclQualifier getObjcDeclQualifier() const { return >> objcDeclQualifier; } >> + >> // Location information, modeled after the Stmt API. >> SourceLocation getLocStart() const { return getLocation(); } >> SourceLocation getLocEnd() const { return EndLoc; } >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > From fjahanian at apple.com Wed Dec 12 11:36:24 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Wed, 12 Dec 2007 09:36:24 -0800 Subject: [cfe-commits] r43948 - in /cfe/trunk: Sema/SemaDecl.cpp Sema/SemaType.cpp test/Sema/method-encoding-2.m In-Reply-To: <2190421E-1A23-4519-A9A0-9BC1205DA4B9@apple.com> References: <200711091718.lA9HIVgW002914@zion.cs.uiuc.edu> <2190421E-1A23-4519-A9A0-9BC1205DA4B9@apple.com> Message-ID: <0668869A-2D7E-44E2-9B9A-7F4572F571B7@apple.com> On Dec 11, 2007, at 11:15 PM, Chris Lattner wrote: > On Nov 9, 2007, at 9:18 AM, Fariborz Jahanian wrote: >> Author: fjahanian >> Date: Fri Nov 9 11:18:29 2007 >> New Revision: 43948 >> >> Insert invisble arguments to method definition header. > > Hi Fariborz, > > The code for handling self etc evolved into: > > void Sema::ObjcActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { > ... > // Create Decl objects for each parameter, entrring them in the > scope for > // binding to their use. > struct DeclaratorChunk::ParamInfo PI; > > // Insert the invisible arguments, self and _cmd! > PI.Ident = &Context.Idents.get("self"); > PI.IdentLoc = SourceLocation(); // synthesized vars have a null > location. > PI.InvalidType = false; > if (MDecl->isInstance()) { > QualType selfTy = Context.getObjcInterfaceType(MDecl- > >getClassInterface()); > selfTy = Context.getPointerType(selfTy); > PI.TypeInfo = selfTy.getAsOpaquePtr(); > } else > PI.TypeInfo = Context.getObjcIdType().getAsOpaquePtr(); > CurMethodDecl->setSelfDecl(ActOnParamDeclarator(PI, FnBodyScope)); > > similarly for _cmd. > > Questions: > > 1. Why are these turning into ParamVarDecls? These are not > parameters in the source language, they are magic variables. I agree that this is an implementation detail. This was a quick way to support binding to the use of 'self' as variable which refers to receiver of message in methods. Post-demo, we talked about providing a special Decl node for the use of 'self' (which requires more substantive changes). > > 2. Why are you setting up a declarator chunk and passing stuff > through ActOnParamDeclarator? This code is in Sema already, so it > seems like this layer of indirection is not needed. I don't remember this code; presumably done to enter the parameter into scope. Maybe Steve has an explanation. - Fariborz > > > -Chris From sabre at nondot.org Wed Dec 12 11:58:05 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 17:58:05 -0000 Subject: [cfe-commits] r44938 - in /cfe/trunk: Sema/SemaDeclObjC.cpp clang.xcodeproj/project.pbxproj include/clang/AST/DeclObjC.h Message-ID: <200712121758.lBCHw55v028289@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 11:58:05 2007 New Revision: 44938 URL: http://llvm.org/viewvc/llvm-project?rev=44938&view=rev Log: unbreak the build. I'm still working on test failures. Modified: cfe/trunk/Sema/SemaDeclObjC.cpp cfe/trunk/clang.xcodeproj/project.pbxproj cfe/trunk/include/clang/AST/DeclObjC.h Modified: cfe/trunk/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDeclObjC.cpp?rev=44938&r1=44937&r2=44938&view=diff ============================================================================== --- cfe/trunk/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/Sema/SemaDeclObjC.cpp Wed Dec 12 11:58:05 2007 @@ -413,13 +413,13 @@ // Check interface's Ivar list against those in the implementation. // names and types must match. // - ObjcIvarDecl** IntfIvars = IDecl->getInstanceVariables(); - int IntfNumIvars = IDecl->getNumInstanceVariables(); unsigned j = 0; bool err = false; - while (numIvars > 0 && IntfNumIvars > 0) { + ObjcInterfaceDecl::ivar_iterator + IVI = IDecl->ivar_begin(), IVE = IDecl->ivar_end(); + for (; numIvars > 0 && IVI != IVE; ++IVI) { ObjcIvarDecl* ImplIvar = ivars[j]; - ObjcIvarDecl* ClsIvar = IntfIvars[j++]; + ObjcIvarDecl* ClsIvar = *IVI; assert (ImplIvar && "missing implementation ivar"); assert (ClsIvar && "missing class ivar"); if (ImplIvar->getCanonicalType() != ClsIvar->getCanonicalType()) { @@ -439,10 +439,9 @@ break; } --numIvars; - --IntfNumIvars; } - if (!err && (numIvars > 0 || IntfNumIvars > 0)) - Diag(numIvars > 0 ? ivars[j]->getLocation() : IntfIvars[j]->getLocation(), + if (!err && (numIvars > 0 || IVI != IVE)) + Diag(numIvars > 0 ? ivars[j]->getLocation() : (*IVI)->getLocation(), diag::err_inconsistant_ivar); } @@ -484,30 +483,31 @@ llvm::DenseSet InsMap; // Check and see if instance methods in class interface have been // implemented in the implementation class. - ObjcMethodDecl *const*methods = IMPDecl->getInstanceMethods(); - for (int i=0; i < IMPDecl->getNumInstanceMethods(); i++) - InsMap.insert(methods[i]->getSelector()); + for (ObjcImplementationDecl::instmeth_iterator I = IMPDecl->instmeth_begin(), + E = IMPDecl->instmeth_end(); I != E; ++I) + InsMap.insert((*I)->getSelector()); bool IncompleteImpl = false; - methods = IDecl->getInstanceMethods(); - for (int j = 0; j < IDecl->getNumInstanceMethods(); j++) - if (!InsMap.count(methods[j]->getSelector())) { - Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, - methods[j]->getSelector().getName()); + for (ObjcInterfaceDecl::instmeth_iterator I = IDecl->instmeth_begin(), + E = IDecl->instmeth_end(); I != E; ++I) + if (!InsMap.count((*I)->getSelector())) { + Diag((*I)->getLocation(), diag::warn_undef_method_impl, + (*I)->getSelector().getName()); IncompleteImpl = true; } + llvm::DenseSet ClsMap; // Check and see if class methods in class interface have been // implemented in the implementation class. - methods = IMPDecl->getClassMethods(); - for (int i=0; i < IMPDecl->getNumClassMethods(); i++) - ClsMap.insert(methods[i]->getSelector()); - - methods = IDecl->getClassMethods(); - for (int j = 0; j < IDecl->getNumClassMethods(); j++) - if (!ClsMap.count(methods[j]->getSelector())) { - Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, - methods[j]->getSelector().getName()); + for (ObjcImplementationDecl::classmeth_iterator I =IMPDecl->classmeth_begin(), + E = IMPDecl->classmeth_end(); I != E; ++I) + ClsMap.insert((*I)->getSelector()); + + for (ObjcInterfaceDecl::classmeth_iterator I = IDecl->classmeth_begin(), + E = IDecl->classmeth_end(); I != E; ++I) + if (!ClsMap.count((*I)->getSelector())) { + Diag((*I)->getLocation(), diag::warn_undef_method_impl, + (*I)->getSelector().getName()); IncompleteImpl = true; } @@ -529,12 +529,12 @@ llvm::DenseSet InsMap; // Check and see if instance methods in category interface have been // implemented in its implementation class. - ObjcMethodDecl *const*methods = CatImplDecl->getInstanceMethods(); - for (int i=0; i < CatImplDecl->getNumInstanceMethods(); i++) - InsMap.insert(methods[i]->getSelector()); + for (ObjcCategoryImplDecl::instmeth_iterator I =CatImplDecl->instmeth_begin(), + E = CatImplDecl->instmeth_end(); I != E; ++I) + InsMap.insert((*I)->getSelector()); bool IncompleteImpl = false; - methods = CatClassDecl->getInstanceMethods(); + ObjcMethodDecl *const* methods = CatClassDecl->getInstanceMethods(); for (int j = 0; j < CatClassDecl->getNumInstanceMethods(); j++) if (!InsMap.count(methods[j]->getSelector())) { Diag(methods[j]->getLocation(), diag::warn_undef_method_impl, @@ -544,9 +544,10 @@ llvm::DenseSet ClsMap; // Check and see if class methods in category interface have been // implemented in its implementation class. - methods = CatImplDecl->getClassMethods(); - for (int i=0; i < CatImplDecl->getNumClassMethods(); i++) - ClsMap.insert(methods[i]->getSelector()); + for (ObjcCategoryImplDecl::classmeth_iterator + I = CatImplDecl->classmeth_begin(), E = CatImplDecl->classmeth_end(); + I != E; ++I) + ClsMap.insert((*I)->getSelector()); methods = CatClassDecl->getClassMethods(); for (int j = 0; j < CatClassDecl->getNumClassMethods(); j++) Modified: cfe/trunk/clang.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=44938&r1=44937&r2=44938&view=diff ============================================================================== --- cfe/trunk/clang.xcodeproj/project.pbxproj (original) +++ cfe/trunk/clang.xcodeproj/project.pbxproj Wed Dec 12 11:58:05 2007 @@ -775,7 +775,6 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; - compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; Modified: cfe/trunk/include/clang/AST/DeclObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=44938&r1=44937&r2=44938&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclObjC.h (original) +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 12 11:58:05 2007 @@ -123,6 +123,18 @@ ObjcMethodDecl** getClassMethods() const { return ClassMethods; } int getNumClassMethods() const { return NumClassMethods; } + typedef ObjcMethodDecl * const * instmeth_iterator; + instmeth_iterator instmeth_begin() const { return InstanceMethods; } + instmeth_iterator instmeth_end() const { + return InstanceMethods+NumInstanceMethods; + } + + typedef ObjcMethodDecl * const * classmeth_iterator; + classmeth_iterator classmeth_begin() const { return ClassMethods; } + classmeth_iterator classmeth_end() const { + return ClassMethods+NumClassMethods; + } + void addInstanceVariablesToClass(ObjcIvarDecl **ivars, unsigned numIvars, SourceLocation RBracLoc); From sabre at nondot.org Wed Dec 12 12:02:31 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 18:02:31 -0000 Subject: [cfe-commits] r44939 - /cfe/trunk/include/clang/AST/DeclObjC.h Message-ID: <200712121802.lBCI2WXs028434@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 12:02:31 2007 New Revision: 44939 URL: http://llvm.org/viewvc/llvm-project?rev=44939&view=rev Log: handle the -1'ness of undefined lists Modified: cfe/trunk/include/clang/AST/DeclObjC.h Modified: cfe/trunk/include/clang/AST/DeclObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=44939&r1=44938&r2=44939&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclObjC.h (original) +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 12 12:02:31 2007 @@ -126,13 +126,13 @@ typedef ObjcMethodDecl * const * instmeth_iterator; instmeth_iterator instmeth_begin() const { return InstanceMethods; } instmeth_iterator instmeth_end() const { - return InstanceMethods+NumInstanceMethods; + return InstanceMethods+(NumInstanceMethods == -1 ? 0 : NumInstanceMethods); } typedef ObjcMethodDecl * const * classmeth_iterator; classmeth_iterator classmeth_begin() const { return ClassMethods; } classmeth_iterator classmeth_end() const { - return ClassMethods+NumClassMethods; + return ClassMethods+(NumClassMethods == -1 ? 0 : NumClassMethods); } void addInstanceVariablesToClass(ObjcIvarDecl **ivars, unsigned numIvars, @@ -620,7 +620,7 @@ typedef ObjcIvarDecl * const *ivar_iterator; ivar_iterator ivar_begin() const { return Ivars; } - ivar_iterator ivar_end() const { return Ivars+NumIvars; } + ivar_iterator ivar_end() const {return Ivars+(NumIvars == -1 ? 0 : NumIvars);} static bool classof(const Decl *D) { return D->getKind() == ObjcImplementation; From kremenek at apple.com Wed Dec 12 12:05:34 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:05:34 -0000 Subject: [cfe-commits] r44940 - in /cfe/trunk: Basic/Targets.cpp Driver/Targets.cpp Driver/TranslationUnit.cpp Driver/clang.cpp Driver/clang.h include/clang/Basic/TargetInfo.h Message-ID: <200712121805.lBCI5YaJ028540@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:05:32 2007 New Revision: 44940 URL: http://llvm.org/viewvc/llvm-project?rev=44940&view=rev Log: Moved construction of TargetInfo objects out of the Driver and into the "Basic" library. TargetInfo objects are now constructed from triples by calling the static method TargetInfo::CreateTargetInfo. Added: cfe/trunk/Basic/Targets.cpp - copied, changed from r44937, cfe/trunk/Driver/Targets.cpp Removed: cfe/trunk/Driver/Targets.cpp Modified: cfe/trunk/Driver/TranslationUnit.cpp cfe/trunk/Driver/clang.cpp cfe/trunk/Driver/clang.h cfe/trunk/include/clang/Basic/TargetInfo.h Copied: cfe/trunk/Basic/Targets.cpp (from r44937, cfe/trunk/Driver/Targets.cpp) URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/Targets.cpp?p2=cfe/trunk/Basic/Targets.cpp&p1=cfe/trunk/Driver/Targets.cpp&r1=44937&r2=44940&rev=44940&view=diff ============================================================================== --- cfe/trunk/Driver/Targets.cpp (original) +++ cfe/trunk/Basic/Targets.cpp Wed Dec 12 12:05:32 2007 @@ -7,19 +7,16 @@ // //===----------------------------------------------------------------------===// // -// This file implements the -arch command line option and creates a TargetInfo -// that represents them. +// This file implements construction of a TargetInfo object from a +// target triple. // //===----------------------------------------------------------------------===// -#include "clang.h" #include "clang/AST/Builtins.h" #include "clang/AST/TargetBuiltins.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/TargetInfo.h" - #include "llvm/ADT/STLExtras.h" -#include "llvm/Support/CommandLine.h" using namespace clang; @@ -702,14 +699,13 @@ /// CreateTargetInfo - Return the set of target info objects as specified by /// the -arch command line option. -TargetInfo *clang::CreateTargetInfo(SourceManager& SrcMgr, - const std::vector& triples, - Diagnostic *Diags) { +TargetInfo* TargetInfo::CreateTargetInfo(SourceManager& SrcMgr, + const std::string* TriplesStart, + const std::string* TriplesEnd, + Diagnostic *Diags) { - assert (!triples.empty() && "No target triple."); - // Create the primary target and target info. - TargetInfoImpl* PrimaryTarget = CreateTarget(triples[0]); + TargetInfoImpl* PrimaryTarget = CreateTarget(*TriplesStart); if (!PrimaryTarget) return NULL; @@ -717,16 +713,18 @@ TargetInfo *TI = new TargetInfo(SrcMgr, PrimaryTarget, Diags); // Add all secondary targets. - for (unsigned i = 1, e = triples.size(); i != e; ++i) { - TargetInfoImpl* SecondaryTarget = CreateTarget(triples[i]); + for (const std::string* I=TriplesStart+1; I != TriplesEnd; ++I) { + TargetInfoImpl* SecondaryTarget = CreateTarget(*I); if (!SecondaryTarget) { - fprintf (stderr, "Warning: secondary target '%s' unrecognized.\n", - triples[i].c_str()); + fprintf (stderr, + "Warning: secondary target '%s' unrecognized.\n", + I->c_str()); + continue; } - TI->AddSecondaryTarget(CreateTarget(triples[i])); + TI->AddSecondaryTarget(SecondaryTarget); } return TI; Removed: cfe/trunk/Driver/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/Targets.cpp?rev=44939&view=auto ============================================================================== --- cfe/trunk/Driver/Targets.cpp (original) +++ cfe/trunk/Driver/Targets.cpp (removed) @@ -1,733 +0,0 @@ -//===--- Targets.cpp - Implement -arch option and targets -----------------===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by Chris Lattner and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the -arch command line option and creates a TargetInfo -// that represents them. -// -//===----------------------------------------------------------------------===// - -#include "clang.h" -#include "clang/AST/Builtins.h" -#include "clang/AST/TargetBuiltins.h" -#include "clang/Basic/Diagnostic.h" -#include "clang/Basic/TargetInfo.h" - -#include "llvm/ADT/STLExtras.h" -#include "llvm/Support/CommandLine.h" - -using namespace clang; - -//===----------------------------------------------------------------------===// -// Common code shared among targets. -//===----------------------------------------------------------------------===// - -static void Define(std::vector &Buf, const char *Macro, - const char *Val = "1") { - const char *Def = "#define "; - Buf.insert(Buf.end(), Def, Def+strlen(Def)); - Buf.insert(Buf.end(), Macro, Macro+strlen(Macro)); - Buf.push_back(' '); - Buf.insert(Buf.end(), Val, Val+strlen(Val)); - Buf.push_back('\n'); -} - - -namespace { -class DarwinTargetInfo : public TargetInfoImpl { -public: - DarwinTargetInfo(const std::string& triple) : TargetInfoImpl(triple) {} - - virtual void getTargetDefines(std::vector &Defs) const { -// FIXME: we need a real target configuration system. For now, only define -// __APPLE__ if the host has it. -#ifdef __APPLE__ - Define(Defs, "__APPLE__"); - Define(Defs, "__MACH__"); -#endif - - if (1) {// -fobjc-gc controls this. - Define(Defs, "__weak", ""); - Define(Defs, "__strong", ""); - } else { - Define(Defs, "__weak", "__attribute__((objc_gc(weak)))"); - Define(Defs, "__strong", "__attribute__((objc_gc(strong)))"); - Define(Defs, "__OBJC_GC__"); - } - - // darwin_constant_cfstrings controls this. - Define(Defs, "__CONSTANT_CFSTRINGS__"); - - if (0) // darwin_pascal_strings - Define(Defs, "__PASCAL_STRINGS__"); - } - -}; -} // end anonymous namespace. - - -/// getPowerPCDefines - Return a set of the PowerPC-specific #defines that are -/// not tied to a specific subtarget. -static void getPowerPCDefines(std::vector &Defs, bool is64Bit) { - // Target identification. - Define(Defs, "__ppc__"); - Define(Defs, "_ARCH_PPC"); - Define(Defs, "__POWERPC__"); - if (is64Bit) { - Define(Defs, "_ARCH_PPC64"); - Define(Defs, "_LP64"); - Define(Defs, "__LP64__"); - Define(Defs, "__ppc64__"); - } else { - Define(Defs, "__ppc__"); - } - - // Target properties. - Define(Defs, "_BIG_ENDIAN"); - Define(Defs, "__BIG_ENDIAN__"); - - if (is64Bit) { - Define(Defs, "__INTMAX_MAX__", "9223372036854775807L"); - Define(Defs, "__INTMAX_TYPE__", "long int"); - Define(Defs, "__LONG_MAX__", "9223372036854775807L"); - Define(Defs, "__PTRDIFF_TYPE__", "long int"); - Define(Defs, "__UINTMAX_TYPE__", "long unsigned int"); - } else { - Define(Defs, "__INTMAX_MAX__", "9223372036854775807LL"); - Define(Defs, "__INTMAX_TYPE__", "long long int"); - Define(Defs, "__LONG_MAX__", "2147483647L"); - Define(Defs, "__PTRDIFF_TYPE__", "int"); - Define(Defs, "__UINTMAX_TYPE__", "long long unsigned int"); - } - Define(Defs, "__INT_MAX__", "2147483647"); - Define(Defs, "__LONG_LONG_MAX__", "9223372036854775807LL"); - Define(Defs, "__CHAR_BIT__", "8"); - Define(Defs, "__SCHAR_MAX__", "127"); - Define(Defs, "__SHRT_MAX__", "32767"); - Define(Defs, "__SIZE_TYPE__", "long unsigned int"); - - // Subtarget options. - Define(Defs, "__USER_LABEL_PREFIX__", "_"); - Define(Defs, "__NATURAL_ALIGNMENT__"); - Define(Defs, "__REGISTER_PREFIX__", ""); - - Define(Defs, "__WCHAR_MAX__", "2147483647"); - Define(Defs, "__WCHAR_TYPE__", "int"); - Define(Defs, "__WINT_TYPE__", "int"); - - // Float macros. - Define(Defs, "__FLT_DENORM_MIN__", "1.40129846e-45F"); - Define(Defs, "__FLT_DIG__", "6"); - Define(Defs, "__FLT_EPSILON__", "1.19209290e-7F"); - Define(Defs, "__FLT_EVAL_METHOD__", "0"); - Define(Defs, "__FLT_HAS_INFINITY__"); - Define(Defs, "__FLT_HAS_QUIET_NAN__"); - Define(Defs, "__FLT_MANT_DIG__", "24"); - Define(Defs, "__FLT_MAX_10_EXP__", "38"); - Define(Defs, "__FLT_MAX_EXP__", "128"); - Define(Defs, "__FLT_MAX__", "3.40282347e+38F"); - Define(Defs, "__FLT_MIN_10_EXP__", "(-37)"); - Define(Defs, "__FLT_MIN_EXP__", "(-125)"); - Define(Defs, "__FLT_MIN__", "1.17549435e-38F"); - Define(Defs, "__FLT_RADIX__", "2"); - - // double macros. - Define(Defs, "__DBL_DENORM_MIN__", "4.9406564584124654e-324"); - Define(Defs, "__DBL_DIG__", "15"); - Define(Defs, "__DBL_EPSILON__", "2.2204460492503131e-16"); - Define(Defs, "__DBL_HAS_INFINITY__"); - Define(Defs, "__DBL_HAS_QUIET_NAN__"); - Define(Defs, "__DBL_MANT_DIG__", "53"); - Define(Defs, "__DBL_MAX_10_EXP__", "308"); - Define(Defs, "__DBL_MAX_EXP__", "1024"); - Define(Defs, "__DBL_MAX__", "1.7976931348623157e+308"); - Define(Defs, "__DBL_MIN_10_EXP__", "(-307)"); - Define(Defs, "__DBL_MIN_EXP__", "(-1021)"); - Define(Defs, "__DBL_MIN__", "2.2250738585072014e-308"); - Define(Defs, "__DECIMAL_DIG__", "33"); - - // 128-bit long double macros. - Define(Defs, "__LDBL_DENORM_MIN__", - "4.94065645841246544176568792868221e-324L"); - Define(Defs, "__LDBL_DIG__", "31"); - Define(Defs, "__LDBL_EPSILON__", - "4.94065645841246544176568792868221e-324L"); - Define(Defs, "__LDBL_HAS_INFINITY__"); - Define(Defs, "__LDBL_HAS_QUIET_NAN__"); - Define(Defs, "__LDBL_MANT_DIG__", "106"); - Define(Defs, "__LDBL_MAX_10_EXP__", "308"); - Define(Defs, "__LDBL_MAX_EXP__", "1024"); - Define(Defs, "__LDBL_MAX__", - "1.79769313486231580793728971405301e+308L"); - Define(Defs, "__LDBL_MIN_10_EXP__", "(-291)"); - Define(Defs, "__LDBL_MIN_EXP__", "(-968)"); - Define(Defs, "__LDBL_MIN__", - "2.00416836000897277799610805135016e-292L"); - Define(Defs, "__LONG_DOUBLE_128__"); -} - -/// getX86Defines - Return a set of the X86-specific #defines that are -/// not tied to a specific subtarget. -static void getX86Defines(std::vector &Defs, bool is64Bit) { - // Target identification. - if (is64Bit) { - Define(Defs, "_LP64"); - Define(Defs, "__LP64__"); - Define(Defs, "__amd64__"); - Define(Defs, "__amd64"); - Define(Defs, "__x86_64"); - Define(Defs, "__x86_64__"); - } else { - Define(Defs, "__i386__"); - Define(Defs, "__i386"); - Define(Defs, "i386"); - } - - // Target properties. - Define(Defs, "__LITTLE_ENDIAN__"); - - if (is64Bit) { - Define(Defs, "__INTMAX_MAX__", "9223372036854775807L"); - Define(Defs, "__INTMAX_TYPE__", "long int"); - Define(Defs, "__LONG_MAX__", "9223372036854775807L"); - Define(Defs, "__PTRDIFF_TYPE__", "long int"); - Define(Defs, "__UINTMAX_TYPE__", "long unsigned int"); - } else { - Define(Defs, "__INTMAX_MAX__", "9223372036854775807LL"); - Define(Defs, "__INTMAX_TYPE__", "long long int"); - Define(Defs, "__LONG_MAX__", "2147483647L"); - Define(Defs, "__PTRDIFF_TYPE__", "int"); - Define(Defs, "__UINTMAX_TYPE__", "long long unsigned int"); - } - Define(Defs, "__CHAR_BIT__", "8"); - Define(Defs, "__INT_MAX__", "2147483647"); - Define(Defs, "__LONG_LONG_MAX__", "9223372036854775807LL"); - Define(Defs, "__SCHAR_MAX__", "127"); - Define(Defs, "__SHRT_MAX__", "32767"); - Define(Defs, "__SIZE_TYPE__", "long unsigned int"); - - // Subtarget options. - Define(Defs, "__nocona"); - Define(Defs, "__nocona__"); - Define(Defs, "__tune_nocona__"); - Define(Defs, "__SSE2_MATH__"); - Define(Defs, "__SSE2__"); - Define(Defs, "__SSE_MATH__"); - Define(Defs, "__SSE__"); - Define(Defs, "__MMX__"); - Define(Defs, "__REGISTER_PREFIX__", ""); - - Define(Defs, "__WCHAR_MAX__", "2147483647"); - Define(Defs, "__WCHAR_TYPE__", "int"); - Define(Defs, "__WINT_TYPE__", "int"); - - // Float macros. - Define(Defs, "__FLT_DENORM_MIN__", "1.40129846e-45F"); - Define(Defs, "__FLT_DIG__", "6"); - Define(Defs, "__FLT_EPSILON__", "1.19209290e-7F"); - Define(Defs, "__FLT_EVAL_METHOD__", "0"); - Define(Defs, "__FLT_HAS_INFINITY__"); - Define(Defs, "__FLT_HAS_QUIET_NAN__"); - Define(Defs, "__FLT_MANT_DIG__", "24"); - Define(Defs, "__FLT_MAX_10_EXP__", "38"); - Define(Defs, "__FLT_MAX_EXP__", "128"); - Define(Defs, "__FLT_MAX__", "3.40282347e+38F"); - Define(Defs, "__FLT_MIN_10_EXP__", "(-37)"); - Define(Defs, "__FLT_MIN_EXP__", "(-125)"); - Define(Defs, "__FLT_MIN__", "1.17549435e-38F"); - Define(Defs, "__FLT_RADIX__", "2"); - - // Double macros. - Define(Defs, "__DBL_DENORM_MIN__", "4.9406564584124654e-324"); - Define(Defs, "__DBL_DIG__", "15"); - Define(Defs, "__DBL_EPSILON__", "2.2204460492503131e-16"); - Define(Defs, "__DBL_HAS_INFINITY__"); - Define(Defs, "__DBL_HAS_QUIET_NAN__"); - Define(Defs, "__DBL_MANT_DIG__", "53"); - Define(Defs, "__DBL_MAX_10_EXP__", "308"); - Define(Defs, "__DBL_MAX_EXP__", "1024"); - Define(Defs, "__DBL_MAX__", "1.7976931348623157e+308"); - Define(Defs, "__DBL_MIN_10_EXP__", "(-307)"); - Define(Defs, "__DBL_MIN_EXP__", "(-1021)"); - Define(Defs, "__DBL_MIN__", "2.2250738585072014e-308"); - Define(Defs, "__DECIMAL_DIG__", "21"); - - // 80-bit Long double macros. - Define(Defs, "__LDBL_DENORM_MIN__", "3.64519953188247460253e-4951L"); - Define(Defs, "__LDBL_DIG__", "18"); - Define(Defs, "__LDBL_EPSILON__", "1.08420217248550443401e-19L"); - Define(Defs, "__LDBL_HAS_INFINITY__"); - Define(Defs, "__LDBL_HAS_QUIET_NAN__"); - Define(Defs, "__LDBL_MANT_DIG__", "64"); - Define(Defs, "__LDBL_MAX_10_EXP__", "4932"); - Define(Defs, "__LDBL_MAX_EXP__", "16384"); - Define(Defs, "__LDBL_MAX__", "1.18973149535723176502e+4932L"); - Define(Defs, "__LDBL_MIN_10_EXP__", "(-4931)"); - Define(Defs, "__LDBL_MIN_EXP__", "(-16381)"); - Define(Defs, "__LDBL_MIN__", "3.36210314311209350626e-4932L"); -} - -static const char* getI386VAListDeclaration() { - return "typedef char* __builtin_va_list;"; -} - -static const char* getX86_64VAListDeclaration() { - return - "typedef struct __va_list_tag {" - " unsigned gp_offset;" - " unsigned fp_offset;" - " void* overflow_arg_area;" - " void* reg_save_area;" - "} __builtin_va_list[1];"; -} - -static const char* getPPCVAListDeclaration() { - return - "typedef struct __va_list_tag {" - " unsigned char gpr;" - " unsigned char fpr;" - " unsigned short reserved;" - " void* overflow_arg_area;" - " void* reg_save_area;" - "} __builtin_va_list[1];"; -} - - -/// PPC builtin info. -namespace clang { -namespace PPC { - - static const Builtin::Info BuiltinInfo[] = { -#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS }, -#include "clang/AST/PPCBuiltins.def" - }; - - static void getBuiltins(const Builtin::Info *&Records, unsigned &NumRecords) { - Records = BuiltinInfo; - NumRecords = LastTSBuiltin-Builtin::FirstTSBuiltin; - } - - static const char * const GCCRegNames[] = { - "0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "10", "11", "12", "13", "14", "15", - "16", "17", "18", "19", "20", "21", "22", "23", - "24", "25", "26", "27", "28", "29", "30", "31", - "0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "10", "11", "12", "13", "14", "15", - "16", "17", "18", "19", "20", "21", "22", "23", - "24", "25", "26", "27", "28", "29", "30", "31", - "mq", "lr", "ctr", "ap", - "0", "1", "2", "3", "4", "5", "6", "7", - "xer", - "0", "1", "2", "3", "4", "5", "6", "7", - "8", "9", "10", "11", "12", "13", "14", "15", - "16", "17", "18", "19", "20", "21", "22", "23", - "24", "25", "26", "27", "28", "29", "30", "31", - "vrsave", "vscr", - "spe_acc", "spefscr", - "sfp" - }; - - static void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) { - Names = GCCRegNames; - NumNames = llvm::array_lengthof(GCCRegNames); - } - - static const TargetInfoImpl::GCCRegAlias GCCRegAliases[] = { - // While some of these aliases do map to different registers - // they still share the same register name. - { { "cc", "cr0", "fr0", "r0", "v0"}, "0" }, - { { "cr1", "fr1", "r1", "sp", "v1"}, "1" }, - { { "cr2", "fr2", "r2", "toc", "v2"}, "2" }, - { { "cr3", "fr3", "r3", "v3"}, "3" }, - { { "cr4", "fr4", "r4", "v4"}, "4" }, - { { "cr5", "fr5", "r5", "v5"}, "5" }, - { { "cr6", "fr6", "r6", "v6"}, "6" }, - { { "cr7", "fr7", "r7", "v7"}, "7" }, - { { "fr8", "r8", "v8"}, "8" }, - { { "fr9", "r9", "v9"}, "9" }, - { { "fr10", "r10", "v10"}, "10" }, - { { "fr11", "r11", "v11"}, "11" }, - { { "fr12", "r12", "v12"}, "12" }, - { { "fr13", "r13", "v13"}, "13" }, - { { "fr14", "r14", "v14"}, "14" }, - { { "fr15", "r15", "v15"}, "15" }, - { { "fr16", "r16", "v16"}, "16" }, - { { "fr17", "r17", "v17"}, "17" }, - { { "fr18", "r18", "v18"}, "18" }, - { { "fr19", "r19", "v19"}, "19" }, - { { "fr20", "r20", "v20"}, "20" }, - { { "fr21", "r21", "v21"}, "21" }, - { { "fr22", "r22", "v22"}, "22" }, - { { "fr23", "r23", "v23"}, "23" }, - { { "fr24", "r24", "v24"}, "24" }, - { { "fr25", "r25", "v25"}, "25" }, - { { "fr26", "r26", "v26"}, "26" }, - { { "fr27", "r27", "v27"}, "27" }, - { { "fr28", "r28", "v28"}, "28" }, - { { "fr29", "r29", "v29"}, "29" }, - { { "fr30", "r30", "v30"}, "30" }, - { { "fr31", "r31", "v31"}, "31" }, - }; - - static void getGCCRegAliases(const TargetInfoImpl::GCCRegAlias *&Aliases, - unsigned &NumAliases) { - Aliases = GCCRegAliases; - NumAliases = llvm::array_lengthof(GCCRegAliases); - } - - static bool validateAsmConstraint(char c, - TargetInfo::ConstraintInfo &info) { - switch (c) { - default: return false; - case 'O': // Zero - return true; - case 'b': // Base register - case 'f': // Floating point register - info = (TargetInfo::ConstraintInfo)(info|TargetInfo::CI_AllowsRegister); - return true; - } - } - - const char *getClobbers() { - return 0; - } - - const char *getTargetPrefix() { - return "ppc"; - } - -} // End namespace PPC - -/// X86 builtin info. -namespace X86 { - static const Builtin::Info BuiltinInfo[] = { -#define BUILTIN(ID, TYPE, ATTRS) { #ID, TYPE, ATTRS }, -#include "clang/AST/X86Builtins.def" - }; - - static void getBuiltins(const Builtin::Info *&Records, unsigned &NumRecords) { - Records = BuiltinInfo; - NumRecords = LastTSBuiltin-Builtin::FirstTSBuiltin; - } - - static const char *GCCRegNames[] = { - "ax", "dx", "cx", "bx", "si", "di", "bp", "sp", - "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)", - "argp", "flags", "fspr", "dirflag", "frame", - "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", - "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15" - }; - - static void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) { - Names = GCCRegNames; - NumNames = llvm::array_lengthof(GCCRegNames); - } - - static const TargetInfoImpl::GCCRegAlias GCCRegAliases[] = { - { { "al", "ah", "eax", "rax" }, "ax" }, - { { "bl", "bh", "ebx", "rbx" }, "bx" }, - { { "cl", "ch", "ecx", "rcx" }, "cx" }, - { { "dl", "dh", "edx", "rdx" }, "dx" }, - { { "esi", "rsi" }, "si" }, - { { "esp", "rsp" }, "sp" }, - { { "ebp", "rbp" }, "bp" }, - }; - - static void getGCCRegAliases(const TargetInfoImpl::GCCRegAlias *&Aliases, - unsigned &NumAliases) { - Aliases = GCCRegAliases; - NumAliases = llvm::array_lengthof(GCCRegAliases); - } - - static bool validateAsmConstraint(char c, - TargetInfo::ConstraintInfo &info) { - switch (c) { - default: return false; - case 'a': // eax. - case 'b': // ebx. - case 'c': // ecx. - case 'd': // edx. - case 'S': // esi. - case 'D': // edi. - case 'A': // edx:eax. - case 't': // top of floating point stack. - case 'u': // second from top of floating point stack. - case 'q': // a, b, c, d registers or any integer register in 64-bit. - info = (TargetInfo::ConstraintInfo)(info|TargetInfo::CI_AllowsRegister); - return true; - } - } - - const char *getClobbers() { - return "~{dirflag},~{fpsr},~{flags}"; - } - - const char *getTargetPrefix() { - return "x86"; - } - -} // End namespace X86 -} // end namespace clang. - -//===----------------------------------------------------------------------===// -// Specific target implementations. -//===----------------------------------------------------------------------===// - - -namespace { -class DarwinPPCTargetInfo : public DarwinTargetInfo { -public: - DarwinPPCTargetInfo(const std::string& triple) : DarwinTargetInfo(triple) {} - - virtual void getTargetDefines(std::vector &Defines) const { - DarwinTargetInfo::getTargetDefines(Defines); - getPowerPCDefines(Defines, false); - } - virtual void getTargetBuiltins(const Builtin::Info *&Records, - unsigned &NumRecords) const { - PPC::getBuiltins(Records, NumRecords); - } - virtual const char *getVAListDeclaration() const { - return getPPCVAListDeclaration(); - } - virtual const char *getTargetPrefix() const { - return PPC::getTargetPrefix(); - } - virtual void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) const { - PPC::getGCCRegNames(Names, NumNames); - } - virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, - unsigned &NumAliases) const { - PPC::getGCCRegAliases(Aliases, NumAliases); - } - virtual bool validateAsmConstraint(char c, - TargetInfo::ConstraintInfo &info) const { - return PPC::validateAsmConstraint(c, info); - } - virtual const char *getClobbers() const { - return PPC::getClobbers(); - } -}; -} // end anonymous namespace. - -namespace { -class DarwinPPC64TargetInfo : public DarwinTargetInfo { -public: - DarwinPPC64TargetInfo(const std::string& triple) : DarwinTargetInfo(triple) {} - - virtual void getTargetDefines(std::vector &Defines) const { - DarwinTargetInfo::getTargetDefines(Defines); - getPowerPCDefines(Defines, true); - } - virtual void getTargetBuiltins(const Builtin::Info *&Records, - unsigned &NumRecords) const { - PPC::getBuiltins(Records, NumRecords); - } - virtual const char *getVAListDeclaration() const { - return getPPCVAListDeclaration(); - } - virtual const char *getTargetPrefix() const { - return PPC::getTargetPrefix(); - } - virtual void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) const { - PPC::getGCCRegNames(Names, NumNames); - } - virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, - unsigned &NumAliases) const { - PPC::getGCCRegAliases(Aliases, NumAliases); - } - virtual bool validateAsmConstraint(char c, - TargetInfo::ConstraintInfo &info) const { - return PPC::validateAsmConstraint(c, info); - } - virtual const char *getClobbers() const { - return PPC::getClobbers(); - } -}; -} // end anonymous namespace. - -namespace { -class DarwinI386TargetInfo : public DarwinTargetInfo { -public: - DarwinI386TargetInfo(const std::string& triple) : DarwinTargetInfo(triple) {} - - virtual void getTargetDefines(std::vector &Defines) const { - DarwinTargetInfo::getTargetDefines(Defines); - getX86Defines(Defines, false); - } - virtual void getTargetBuiltins(const Builtin::Info *&Records, - unsigned &NumRecords) const { - X86::getBuiltins(Records, NumRecords); - } - virtual const char *getVAListDeclaration() const { - return getI386VAListDeclaration(); - } - virtual const char *getTargetPrefix() const { - return X86::getTargetPrefix(); - } - virtual void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) const { - X86::getGCCRegNames(Names, NumNames); - } - virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, - unsigned &NumAliases) const { - X86::getGCCRegAliases(Aliases, NumAliases); - } - virtual bool validateAsmConstraint(char c, - TargetInfo::ConstraintInfo &info) const { - return X86::validateAsmConstraint(c, info); - } - virtual const char *getClobbers() const { - return X86::getClobbers(); - } -}; -} // end anonymous namespace. - -namespace { -class DarwinX86_64TargetInfo : public DarwinTargetInfo { -public: - DarwinX86_64TargetInfo(const std::string& triple) :DarwinTargetInfo(triple) {} - - virtual void getTargetDefines(std::vector &Defines) const { - DarwinTargetInfo::getTargetDefines(Defines); - getX86Defines(Defines, true); - } - virtual void getTargetBuiltins(const Builtin::Info *&Records, - unsigned &NumRecords) const { - X86::getBuiltins(Records, NumRecords); - } - virtual const char *getVAListDeclaration() const { - return getX86_64VAListDeclaration(); - } - virtual const char *getTargetPrefix() const { - return X86::getTargetPrefix(); - } - virtual void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) const { - X86::getGCCRegNames(Names, NumNames); - } - virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, - unsigned &NumAliases) const { - X86::getGCCRegAliases(Aliases, NumAliases); - } - virtual bool validateAsmConstraint(char c, - TargetInfo::ConstraintInfo &info) const { - return X86::validateAsmConstraint(c, info); - } - virtual const char *getClobbers() const { - return X86::getClobbers(); - } -}; -} // end anonymous namespace. - -namespace { -class LinuxTargetInfo : public DarwinTargetInfo { -public: - LinuxTargetInfo(const std::string& triple) : DarwinTargetInfo(triple) { - // Note: I have no idea if this is right, just for testing. - WCharWidth = 16; - WCharAlign = 16; - } - - virtual void getTargetDefines(std::vector &Defines) const { - // TODO: linux-specific stuff. - getX86Defines(Defines, false); - } - virtual void getTargetBuiltins(const Builtin::Info *&Records, - unsigned &NumRecords) const { - X86::getBuiltins(Records, NumRecords); - } - virtual const char *getVAListDeclaration() const { - return getI386VAListDeclaration(); - } - virtual const char *getTargetPrefix() const { - return X86::getTargetPrefix(); - } - virtual void getGCCRegNames(const char * const *&Names, - unsigned &NumNames) const { - X86::getGCCRegNames(Names, NumNames); - } - virtual void getGCCRegAliases(const GCCRegAlias *&Aliases, - unsigned &NumAliases) const { - X86::getGCCRegAliases(Aliases, NumAliases); - } - virtual bool validateAsmConstraint(char c, - TargetInfo::ConstraintInfo &info) const { - return X86::validateAsmConstraint(c, info); - } - virtual const char *getClobbers() const { - return X86::getClobbers(); - } -}; -} // end anonymous namespace. - - -//===----------------------------------------------------------------------===// -// Driver code -//===----------------------------------------------------------------------===// - -static inline bool IsX86(const std::string& TT) { - return (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' && - TT[4] == '-' && TT[1] - '3' < 6); -} - -/// CreateTarget - Create the TargetInfoImpl object for the specified target -/// enum value. -static TargetInfoImpl *CreateTarget(const std::string& T) { - if (T.find("ppc-") == 0 || T.find("powerpc-") == 0) - return new DarwinPPCTargetInfo(T); - else if (T.find("ppc64-") == 0 || T.find("powerpc64-") == 0) - return new DarwinPPC64TargetInfo(T); - else if (T.find("x86_64-") == 0) - return new DarwinX86_64TargetInfo(T); - else if (IsX86(T)) - return new DarwinI386TargetInfo(T); - else if (T.find("bogusW16W16-") == 0) // For testing portability. - return new LinuxTargetInfo(T); - else - return NULL; -} - -/// CreateTargetInfo - Return the set of target info objects as specified by -/// the -arch command line option. -TargetInfo *clang::CreateTargetInfo(SourceManager& SrcMgr, - const std::vector& triples, - Diagnostic *Diags) { - - assert (!triples.empty() && "No target triple."); - - // Create the primary target and target info. - TargetInfoImpl* PrimaryTarget = CreateTarget(triples[0]); - - if (!PrimaryTarget) - return NULL; - - TargetInfo *TI = new TargetInfo(SrcMgr, PrimaryTarget, Diags); - - // Add all secondary targets. - for (unsigned i = 1, e = triples.size(); i != e; ++i) { - TargetInfoImpl* SecondaryTarget = CreateTarget(triples[i]); - - if (!SecondaryTarget) { - fprintf (stderr, "Warning: secondary target '%s' unrecognized.\n", - triples[i].c_str()); - continue; - } - - TI->AddSecondaryTarget(CreateTarget(triples[i])); - } - - return TI; -} Modified: cfe/trunk/Driver/TranslationUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TranslationUnit.cpp?rev=44940&r1=44939&r2=44940&view=diff ============================================================================== --- cfe/trunk/Driver/TranslationUnit.cpp (original) +++ cfe/trunk/Driver/TranslationUnit.cpp Wed Dec 12 12:05:32 2007 @@ -189,14 +189,14 @@ // Read the LangOptions. TU->LangOpts.Read(Dezr); - { - // Read the TargetInfo. + { // Read the TargetInfo. llvm::SerializedPtrID PtrID = Dezr.ReadPtrID(); char* triple = Dezr.ReadCStr(NULL,0,true); - std::vector triples; - triples.push_back(triple); + std::string Triple(triple); + Dezr.RegisterPtr(PtrID,TargetInfo::CreateTargetInfo(SrcMgr, + &Triple, + &Triple+1)); delete [] triple; - Dezr.RegisterPtr(PtrID,CreateTargetInfo(SrcMgr,triples,NULL)); } // For Selectors, we must read the identifier table first because the Modified: cfe/trunk/Driver/clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=44940&r1=44939&r2=44940&view=diff ============================================================================== --- cfe/trunk/Driver/clang.cpp (original) +++ cfe/trunk/Driver/clang.cpp Wed Dec 12 12:05:32 2007 @@ -1019,7 +1019,10 @@ // Create triples, and create the TargetInfo. std::vector triples; CreateTargetTriples(triples); - Target = CreateTargetInfo(SourceMgr,triples,&Diags); + Target = TargetInfo::CreateTargetInfo(SourceMgr, + &triples[0], + &triples[0]+triples.size(), + &Diags); if (Target == 0) { fprintf(stderr, "Sorry, I don't know what target this is: %s\n", Modified: cfe/trunk/Driver/clang.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.h?rev=44940&r1=44939&r2=44940&view=diff ============================================================================== --- cfe/trunk/Driver/clang.h (original) +++ cfe/trunk/Driver/clang.h Wed Dec 12 12:05:32 2007 @@ -35,12 +35,6 @@ /// implements the -parse-print-callbacks option. MinimalAction *CreatePrintParserActionsAction(IdentifierTable &); -/// CreateTargetInfo - Return the set of target info objects as specified by -/// the -arch command line option. -TargetInfo *CreateTargetInfo(SourceManager& SrcMgr, - const std::vector& triples, - Diagnostic *Diags); - /// EmitLLVMFromASTs - Implement -emit-llvm, which generates llvm IR from C. void EmitLLVMFromASTs(Preprocessor &PP, unsigned MainFileID, bool PrintStats); Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=44940&r1=44939&r2=44940&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Dec 12 12:05:32 2007 @@ -64,8 +64,11 @@ /// These are all caches for target values. unsigned WCharWidth, WCharAlign; + + //==----------------------------------------------------------------==/ + // TargetInfo Construction. + //==----------------------------------------------------------------==/ -public: TargetInfo(SourceManager& SMgr, const TargetInfoImpl *Primary, Diagnostic *D = 0) : SrcMgr(SMgr) { PrimaryTarget = Primary; @@ -75,6 +78,19 @@ // Initialize Cache values to uncomputed. WCharWidth = 0; } + +public: + /// CreateTargetInfo - Create a TargetInfo object from a group of + /// target triples. The first target triple is considered the primary + /// target. + static TargetInfo* CreateTargetInfo(SourceManager& SrcMgr, + const std::string* TriplesBeg, + const std::string* TripledEnd, + Diagnostic* Diags = NULL); + + //==----------------------------------------------------------------==/ + // Accessors. + //==----------------------------------------------------------------==/ /// isNonPortable - Return true if the current translation unit has used a /// target property that is non-portable across the secondary targets. From sabre at nondot.org Wed Dec 12 12:11:49 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 18:11:49 -0000 Subject: [cfe-commits] r44941 - /cfe/trunk/Sema/SemaDeclObjC.cpp Message-ID: <200712121811.lBCIBnMU028747@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 12:11:49 2007 New Revision: 44941 URL: http://llvm.org/viewvc/llvm-project?rev=44941&view=rev Log: simplify some code, bump j. This fixes the remaining test failures. Modified: cfe/trunk/Sema/SemaDeclObjC.cpp Modified: cfe/trunk/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDeclObjC.cpp?rev=44941&r1=44940&r2=44941&view=diff ============================================================================== --- cfe/trunk/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/Sema/SemaDeclObjC.cpp Wed Dec 12 12:11:49 2007 @@ -414,11 +414,10 @@ // names and types must match. // unsigned j = 0; - bool err = false; ObjcInterfaceDecl::ivar_iterator IVI = IDecl->ivar_begin(), IVE = IDecl->ivar_end(); for (; numIvars > 0 && IVI != IVE; ++IVI) { - ObjcIvarDecl* ImplIvar = ivars[j]; + ObjcIvarDecl* ImplIvar = ivars[j++]; ObjcIvarDecl* ClsIvar = *IVI; assert (ImplIvar && "missing implementation ivar"); assert (ClsIvar && "missing class ivar"); @@ -435,15 +434,15 @@ ImplIvar->getIdentifier()->getName()); Diag(ClsIvar->getLocation(), diag::err_previous_definition, ClsIvar->getIdentifier()->getName()); - err = true; - break; + return; } --numIvars; } - if (!err && (numIvars > 0 || IVI != IVE)) - Diag(numIvars > 0 ? ivars[j]->getLocation() : (*IVI)->getLocation(), - diag::err_inconsistant_ivar); - + + if (numIvars > 0) + Diag(ivars[j]->getLocation(), diag::err_inconsistant_ivar); + else if (IVI != IVE) + Diag((*IVI)->getLocation(), diag::err_inconsistant_ivar); } /// CheckProtocolMethodDefs - This routine checks unimpletented methods From kremenek at apple.com Wed Dec 12 12:16:46 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:16:46 -0000 Subject: [cfe-commits] r44942 - /cfe/trunk/include/clang/Basic/SourceLocation.h Message-ID: <200712121816.lBCIGkap028919@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:16:46 2007 New Revision: 44942 URL: http://llvm.org/viewvc/llvm-project?rev=44942&view=rev Log: Added class FullContextSourceLocation: a tuple class that contains both a SourceLocation and its associated SourceManager. This class is useful for argument passing to functions that expect both objects. Modified: cfe/trunk/include/clang/Basic/SourceLocation.h Modified: cfe/trunk/include/clang/Basic/SourceLocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=44942&r1=44941&r2=44942&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/SourceLocation.h (original) +++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Dec 12 12:16:46 2007 @@ -18,6 +18,8 @@ #include "llvm/Bitcode/SerializationFwd.h" namespace clang { + +class SourceManager; /// SourceLocation - This is a carefully crafted 32-bit identifier that encodes /// a full include stack, line and column number information for a position in @@ -199,6 +201,35 @@ static SourceRange ReadVal(llvm::Deserializer& D); }; +/// FullContextSourceLocation - A tuple containing both a SourceLocation +/// and its associated SourceManager. Useful for argument passing to functions +/// that expect both objects. +class FullContextSourceLocation { + SourceLocation Loc; + SourceManager* SrcMgr; +public: + explicit FullContextSourceLocation(SourceLocation loc) + : Loc(loc), SrcMgr(NULL) {} + + explicit FullContextSourceLocation(SourceLocation loc, SourceManager& smgr) + : Loc(loc), SrcMgr(&smgr) {} + + bool isValid() { return Loc.isValid(); } + + SourceLocation getSourceLocation() const { return Loc; } + operator SourceLocation() const { return Loc; } + + SourceManager& getSourceManager() { + assert (SrcMgr && "SourceManager is NULL."); + return *SrcMgr; + } + + const SourceManager& getSourceManager() const { + assert (SrcMgr && "SourceManager is NULL."); + return *SrcMgr; + } +}; + } // end namespace clang #endif From kremenek at apple.com Wed Dec 12 12:18:05 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:18:05 -0000 Subject: [cfe-commits] r44943 - /cfe/trunk/include/clang/Basic/SourceLocation.h Message-ID: <200712121818.lBCII5Bs029005@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:18:05 2007 New Revision: 44943 URL: http://llvm.org/viewvc/llvm-project?rev=44943&view=rev Log: Constified a predicate method. Modified: cfe/trunk/include/clang/Basic/SourceLocation.h Modified: cfe/trunk/include/clang/Basic/SourceLocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=44943&r1=44942&r2=44943&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/SourceLocation.h (original) +++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Dec 12 12:18:05 2007 @@ -214,7 +214,7 @@ explicit FullContextSourceLocation(SourceLocation loc, SourceManager& smgr) : Loc(loc), SrcMgr(&smgr) {} - bool isValid() { return Loc.isValid(); } + bool isValid() const { return Loc.isValid(); } SourceLocation getSourceLocation() const { return Loc; } operator SourceLocation() const { return Loc; } From sabre at nondot.org Wed Dec 12 12:19:34 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 18:19:34 -0000 Subject: [cfe-commits] r44944 - /cfe/trunk/include/clang/AST/DeclObjC.h Message-ID: <200712121819.lBCIJYYJ029134@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 12:19:33 2007 New Revision: 44944 URL: http://llvm.org/viewvc/llvm-project?rev=44944&view=rev Log: add an ivar_size() method that never returns -1. Modified: cfe/trunk/include/clang/AST/DeclObjC.h Modified: cfe/trunk/include/clang/AST/DeclObjC.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=44944&r1=44943&r2=44944&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/DeclObjC.h (original) +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 12 12:19:33 2007 @@ -114,8 +114,9 @@ int getNumInstanceVariables() const { return NumIvars; } typedef ObjcIvarDecl * const *ivar_iterator; + unsigned ivar_size() const { return NumIvars == -1 ?0 : NumIvars; } ivar_iterator ivar_begin() const { return Ivars; } - ivar_iterator ivar_end() const { return Ivars+(NumIvars == -1 ?0 : NumIvars);} + ivar_iterator ivar_end() const { return Ivars + ivar_size();} ObjcMethodDecl** getInstanceMethods() const { return InstanceMethods; } int getNumInstanceMethods() const { return NumInstanceMethods; } From sabre at nondot.org Wed Dec 12 12:19:53 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 18:19:53 -0000 Subject: [cfe-commits] r44945 - in /cfe/trunk: Sema/SemaDeclObjC.cpp include/clang/Basic/DiagnosticKinds.def Message-ID: <200712121819.lBCIJr3x029162@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 12:19:52 2007 New Revision: 44945 URL: http://llvm.org/viewvc/llvm-project?rev=44945&view=rev Log: make it a bit more clear in what way the ivar is consistent. Modified: cfe/trunk/Sema/SemaDeclObjC.cpp cfe/trunk/include/clang/Basic/DiagnosticKinds.def Modified: cfe/trunk/Sema/SemaDeclObjC.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDeclObjC.cpp?rev=44945&r1=44944&r2=44945&view=diff ============================================================================== --- cfe/trunk/Sema/SemaDeclObjC.cpp (original) +++ cfe/trunk/Sema/SemaDeclObjC.cpp Wed Dec 12 12:19:52 2007 @@ -440,9 +440,9 @@ } if (numIvars > 0) - Diag(ivars[j]->getLocation(), diag::err_inconsistant_ivar); + Diag(ivars[j]->getLocation(), diag::err_inconsistant_ivar_count); else if (IVI != IVE) - Diag((*IVI)->getLocation(), diag::err_inconsistant_ivar); + Diag((*IVI)->getLocation(), diag::err_inconsistant_ivar_count); } /// CheckProtocolMethodDefs - This routine checks unimpletented methods Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=44945&r1=44944&r2=44945&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original) +++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Wed Dec 12 12:19:52 2007 @@ -436,8 +436,8 @@ "conflicting super class name '%0'") DIAG(err_conflicting_ivar_name, ERROR, "conflicting instance variable name '%0'") -DIAG(err_inconsistant_ivar, ERROR, - "inconsistent instance variable specification") +DIAG(err_inconsistant_ivar_count, ERROR, + "inconsistent number of instance variables specified") DIAG(err_conflicting_ivar_type, ERROR, "conflicting instance variable type") DIAG(warn_undef_method_impl, WARNING, From kremenek at apple.com Wed Dec 12 12:20:36 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:20:36 -0000 Subject: [cfe-commits] r44946 - /cfe/trunk/include/clang/Basic/SourceLocation.h Message-ID: <200712121820.lBCIKats029222@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:20:34 2007 New Revision: 44946 URL: http://llvm.org/viewvc/llvm-project?rev=44946&view=rev Log: Added utility static method to FullContextSourceLocation for creating "invalid" location objects. Modified: cfe/trunk/include/clang/Basic/SourceLocation.h Modified: cfe/trunk/include/clang/Basic/SourceLocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=44946&r1=44945&r2=44946&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/SourceLocation.h (original) +++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Dec 12 12:20:34 2007 @@ -214,6 +214,10 @@ explicit FullContextSourceLocation(SourceLocation loc, SourceManager& smgr) : Loc(loc), SrcMgr(&smgr) {} + static FullContextSourceLocation CreateInvalidLocation() { + return FullContextSourceLocation(SourceLocation()); + } + bool isValid() const { return Loc.isValid(); } SourceLocation getSourceLocation() const { return Loc; } From kremenek at apple.com Wed Dec 12 12:32:04 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:32:04 -0000 Subject: [cfe-commits] r44947 - /cfe/trunk/include/clang/Basic/SourceLocation.h Message-ID: <200712121832.lBCIW4bo029702@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:32:04 2007 New Revision: 44947 URL: http://llvm.org/viewvc/llvm-project?rev=44947&view=rev Log: Renamed FullContextSourceLocation to FullSourceLoc. Modified: cfe/trunk/include/clang/Basic/SourceLocation.h Modified: cfe/trunk/include/clang/Basic/SourceLocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=44947&r1=44946&r2=44947&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/SourceLocation.h (original) +++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Dec 12 12:32:04 2007 @@ -201,21 +201,21 @@ static SourceRange ReadVal(llvm::Deserializer& D); }; -/// FullContextSourceLocation - A tuple containing both a SourceLocation +/// FullSourceLoc - A tuple containing both a SourceLocation /// and its associated SourceManager. Useful for argument passing to functions /// that expect both objects. -class FullContextSourceLocation { +class FullSourceLoc { SourceLocation Loc; SourceManager* SrcMgr; public: - explicit FullContextSourceLocation(SourceLocation loc) + explicit FullSourceLoc(SourceLocation loc) : Loc(loc), SrcMgr(NULL) {} - explicit FullContextSourceLocation(SourceLocation loc, SourceManager& smgr) + explicit FullSourceLoc(SourceLocation loc, SourceManager& smgr) : Loc(loc), SrcMgr(&smgr) {} - static FullContextSourceLocation CreateInvalidLocation() { - return FullContextSourceLocation(SourceLocation()); + static FullSourceLoc CreateInvalidLocation() { + return FullSourceLoc(SourceLocation()); } bool isValid() const { return Loc.isValid(); } From kremenek at apple.com Wed Dec 12 12:41:41 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:41:41 -0000 Subject: [cfe-commits] r44948 - /cfe/trunk/include/clang/Lex/Preprocessor.h Message-ID: <200712121841.lBCIffM1030379@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:41:40 2007 New Revision: 44948 URL: http://llvm.org/viewvc/llvm-project?rev=44948&view=rev Log: Added method: Preprocessor::getFullSourceLoc. Used by clients of Preprocessor to get a FullSourceLoc from a SourceLocation. Modified: cfe/trunk/include/clang/Lex/Preprocessor.h Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=44948&r1=44947&r2=44948&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Dec 12 12:41:40 2007 @@ -152,6 +152,10 @@ IdentifierTable &getIdentifierTable() { return Identifiers; } SelectorTable &getSelectorTable() { return Selectors; } + inline FullSourceLoc getFullSourceLoc(SourceLocation Loc) { + return FullSourceLoc(Loc,getSourceManager()); + } + /// SetCommentRetentionState - Control whether or not the preprocessor retains /// comments in output. void SetCommentRetentionState(bool KeepComments, bool KeepMacroComments) { From clattner at apple.com Wed Dec 12 12:43:11 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 10:43:11 -0800 Subject: [cfe-commits] r44942 - /cfe/trunk/include/clang/Basic/SourceLocation.h In-Reply-To: <200712121816.lBCIGkap028919@zion.cs.uiuc.edu> References: <200712121816.lBCIGkap028919@zion.cs.uiuc.edu> Message-ID: <18E2A16E-EF24-4477-B439-F1468EF1B7F9@apple.com> > URL: http://llvm.org/viewvc/llvm-project?rev=44942&view=rev > Log: > Added class FullContextSourceLocation: a tuple class that > contains both a SourceLocation and its associated > SourceManager. This class is useful for argument passing to > functions that expect both objects. Hey Ted, > +/// FullContextSourceLocation - A tuple containing both a > SourceLocation > +/// and its associated SourceManager. Useful for argument > passing to functions > +/// that expect both objects. > +class FullContextSourceLocation { > + SourceLocation Loc; > + SourceManager* SrcMgr; > +public: Ok. > + explicit FullContextSourceLocation(SourceLocation loc) > + : Loc(loc), SrcMgr(NULL) {} I don't think we want to support fullsourceloc's with a null srcmgr unless the location is invalid. It seems best to support two ctors: a default ctor that makes an invalid sloc, and a version that takes both. > + > + explicit FullContextSourceLocation(SourceLocation loc, > SourceManager& smgr) > + : Loc(loc), SrcMgr(&smgr) {} I think all clients that decode the sloc only need read-only access to the source manager. I'd suggest making all references to it const. > + SourceLocation getSourceLocation() const { return Loc; } > + operator SourceLocation() const { return Loc; } Ick. Please name this getLoc(), and remove the implicit conversion :) > + > + SourceManager& getSourceManager() { Please drop this one (no need for a non-const one). > + const SourceManager& getSourceManager() const { How about getManager() ? -Chris From kremenek at apple.com Wed Dec 12 12:45:22 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 10:45:22 -0800 Subject: [cfe-commits] r44942 - /cfe/trunk/include/clang/Basic/SourceLocation.h In-Reply-To: <18E2A16E-EF24-4477-B439-F1468EF1B7F9@apple.com> References: <200712121816.lBCIGkap028919@zion.cs.uiuc.edu> <18E2A16E-EF24-4477-B439-F1468EF1B7F9@apple.com> Message-ID: <5399440D-2357-4C21-BF91-EFB069A33657@apple.com> On Dec 12, 2007, at 10:43 AM, Chris Lattner wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=44942&view=rev >> Log: >> Added class FullContextSourceLocation: a tuple class that >> contains both a SourceLocation and its associated >> SourceManager. This class is useful for argument passing to >> functions that expect both objects. > > Hey Ted, > > >> +/// FullContextSourceLocation - A tuple containing both a >> SourceLocation >> +/// and its associated SourceManager. Useful for argument >> passing to functions >> +/// that expect both objects. >> +class FullContextSourceLocation { >> + SourceLocation Loc; >> + SourceManager* SrcMgr; >> +public: > > Ok. > >> + explicit FullContextSourceLocation(SourceLocation loc) >> + : Loc(loc), SrcMgr(NULL) {} > > I don't think we want to support fullsourceloc's with a null srcmgr > unless the location is invalid. It seems best to support two ctors: > a default ctor that makes an invalid sloc, and a version that takes > both. > >> + >> + explicit FullContextSourceLocation(SourceLocation loc, >> SourceManager& smgr) >> + : Loc(loc), SrcMgr(&smgr) {} > > I think all clients that decode the sloc only need read-only access > to the source manager. I'd suggest making all references to it const. > >> + SourceLocation getSourceLocation() const { return Loc; } >> + operator SourceLocation() const { return Loc; } > > Ick. Please name this getLoc(), and remove the implicit conversion :) > >> + >> + SourceManager& getSourceManager() { > > Please drop this one (no need for a non-const one). > >> + const SourceManager& getSourceManager() const { > > How about getManager() ? > > -Chris Agreed on all counts. From kremenek at apple.com Wed Dec 12 12:46:37 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:46:37 -0000 Subject: [cfe-commits] r44949 - /cfe/trunk/include/clang/Lex/Preprocessor.h Message-ID: <200712121846.lBCIkbpV031028@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:46:37 2007 New Revision: 44949 URL: http://llvm.org/viewvc/llvm-project?rev=44949&view=rev Log: Renamed getFullSourceLoc() -> getFullLoc(). Modified: cfe/trunk/include/clang/Lex/Preprocessor.h Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=44949&r1=44948&r2=44949&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Dec 12 12:46:37 2007 @@ -152,7 +152,7 @@ IdentifierTable &getIdentifierTable() { return Identifiers; } SelectorTable &getSelectorTable() { return Selectors; } - inline FullSourceLoc getFullSourceLoc(SourceLocation Loc) { + inline FullSourceLoc getFullLoc(SourceLocation Loc) { return FullSourceLoc(Loc,getSourceManager()); } From kremenek at apple.com Wed Dec 12 12:54:23 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:54:23 -0000 Subject: [cfe-commits] r44950 - /cfe/trunk/include/clang/Basic/SourceLocation.h Message-ID: <200712121854.lBCIsOJp031697@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:54:21 2007 New Revision: 44950 URL: http://llvm.org/viewvc/llvm-project?rev=44950&view=rev Log: Changes to FullSourceLoc: - Added cstor that takes no arguments to create an "invalid" location. - Removed non-const version of getSourceManager(). - Renamed getSourceManager() to getManager. - Remover operator SourceLocatio(). Modified: cfe/trunk/include/clang/Basic/SourceLocation.h Modified: cfe/trunk/include/clang/Basic/SourceLocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=44950&r1=44949&r2=44950&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/SourceLocation.h (original) +++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Dec 12 12:54:21 2007 @@ -206,29 +206,21 @@ /// that expect both objects. class FullSourceLoc { SourceLocation Loc; - SourceManager* SrcMgr; + const SourceManager* SrcMgr; public: - explicit FullSourceLoc(SourceLocation loc) - : Loc(loc), SrcMgr(NULL) {} + // Creates a FullSourceLoc where isValid() returns false. + explicit FullSourceLoc() : Loc(SourceLocation()), SrcMgr(NULL) {} - explicit FullSourceLoc(SourceLocation loc, SourceManager& smgr) - : Loc(loc), SrcMgr(&smgr) {} - - static FullSourceLoc CreateInvalidLocation() { - return FullSourceLoc(SourceLocation()); + explicit FullSourceLoc(SourceLocation loc, const SourceManager& smgr) + : Loc(loc), SrcMgr(&smgr) { + assert (loc.isValid() && "SourceLocation must be valid!"); } - + bool isValid() const { return Loc.isValid(); } SourceLocation getSourceLocation() const { return Loc; } - operator SourceLocation() const { return Loc; } - - SourceManager& getSourceManager() { - assert (SrcMgr && "SourceManager is NULL."); - return *SrcMgr; - } - const SourceManager& getSourceManager() const { + const SourceManager& getManager() const { assert (SrcMgr && "SourceManager is NULL."); return *SrcMgr; } From kremenek at apple.com Wed Dec 12 12:55:37 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 18:55:37 -0000 Subject: [cfe-commits] r44951 - /cfe/trunk/include/clang/Lex/Preprocessor.h Message-ID: <200712121855.lBCItb0s031762@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 12:55:29 2007 New Revision: 44951 URL: http://llvm.org/viewvc/llvm-project?rev=44951&view=rev Log: constified getFullLoc(). Modified: cfe/trunk/include/clang/Lex/Preprocessor.h Modified: cfe/trunk/include/clang/Lex/Preprocessor.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=44951&r1=44950&r2=44951&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/Preprocessor.h (original) +++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Dec 12 12:55:29 2007 @@ -152,7 +152,7 @@ IdentifierTable &getIdentifierTable() { return Identifiers; } SelectorTable &getSelectorTable() { return Selectors; } - inline FullSourceLoc getFullLoc(SourceLocation Loc) { + inline FullSourceLoc getFullLoc(SourceLocation Loc) const { return FullSourceLoc(Loc,getSourceManager()); } From kremenek at apple.com Wed Dec 12 13:39:41 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 19:39:41 -0000 Subject: [cfe-commits] r44953 - /cfe/trunk/include/clang/Basic/SourceLocation.h Message-ID: <200712121939.lBCJdfPN002084@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 13:39:40 2007 New Revision: 44953 URL: http://llvm.org/viewvc/llvm-project?rev=44953&view=rev Log: Removed "NULL" from default construction of FullSourceLoc (compilation errors on some systems). Modified: cfe/trunk/include/clang/Basic/SourceLocation.h Modified: cfe/trunk/include/clang/Basic/SourceLocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=44953&r1=44952&r2=44953&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/SourceLocation.h (original) +++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Dec 12 13:39:40 2007 @@ -209,7 +209,8 @@ const SourceManager* SrcMgr; public: // Creates a FullSourceLoc where isValid() returns false. - explicit FullSourceLoc() : Loc(SourceLocation()), SrcMgr(NULL) {} + explicit FullSourceLoc() + : Loc(SourceLocation()), SrcMgr((SourceManager*) 0) {} explicit FullSourceLoc(SourceLocation loc, const SourceManager& smgr) : Loc(loc), SrcMgr(&smgr) { From snaroff at apple.com Wed Dec 12 16:30:12 2007 From: snaroff at apple.com (Steve Naroff) Date: Wed, 12 Dec 2007 22:30:12 -0000 Subject: [cfe-commits] r44956 - in /cfe/trunk: AST/ASTContext.cpp clang.xcodeproj/project.pbxproj Message-ID: <200712122230.lBCMUCMu014284@zion.cs.uiuc.edu> Author: snaroff Date: Wed Dec 12 16:30:11 2007 New Revision: 44956 URL: http://llvm.org/viewvc/llvm-project?rev=44956&view=rev Log: Encode enumeral types. Modified: cfe/trunk/AST/ASTContext.cpp cfe/trunk/clang.xcodeproj/project.pbxproj Modified: cfe/trunk/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=44956&r1=44955&r2=44956&view=diff ============================================================================== --- cfe/trunk/AST/ASTContext.cpp (original) +++ cfe/trunk/AST/ASTContext.cpp Wed Dec 12 16:30:11 2007 @@ -1071,8 +1071,10 @@ getObjcEncodingForType(field->getType(), S); } S += '}'; + } else if (T->isEnumeralType()) { + S += 'i'; } else - assert(0 && "@encode for type not implemented!"); + assert(0 && "@encode for type not implemented!"); } void ASTContext::getObjcEncodingForTypeQualifier(Decl::ObjcDeclQualifier QT, Modified: cfe/trunk/clang.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=44956&r1=44955&r2=44956&view=diff ============================================================================== --- cfe/trunk/clang.xcodeproj/project.pbxproj (original) +++ cfe/trunk/clang.xcodeproj/project.pbxproj Wed Dec 12 16:30:11 2007 @@ -775,6 +775,7 @@ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */; + compatibilityVersion = "Xcode 2.4"; hasScannedForEncodings = 1; mainGroup = 08FB7794FE84155DC02AAC07 /* clang */; projectDirPath = ""; From kremenek at apple.com Wed Dec 12 16:39:37 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 22:39:37 -0000 Subject: [cfe-commits] r44957 - in /cfe/trunk: AST/ Analysis/ Basic/ CodeGen/ Driver/ Lex/ Parse/ Sema/ include/clang/AST/ include/clang/Basic/ include/clang/Parse/ Message-ID: <200712122239.lBCMdcr9014698@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 16:39:36 2007 New Revision: 44957 URL: http://llvm.org/viewvc/llvm-project?rev=44957&view=rev Log: TargetInfo no longer includes a reference to SourceManager. Moved all clients of Diagnostics to use FullSourceLoc instead of SourceLocation. Added many utility methods to FullSourceLoc to provide shorthand for: FullLoc.getManager().someMethod(FullLoc.getLocation()); instead we have: FullLoc.someMethod(); Modified TextDiagnostics (and related classes) to use this short-hand. Modified: cfe/trunk/AST/ASTContext.cpp cfe/trunk/AST/Expr.cpp cfe/trunk/Analysis/DeadStores.cpp cfe/trunk/Analysis/UninitializedValues.cpp cfe/trunk/Basic/Diagnostic.cpp cfe/trunk/Basic/SourceLocation.cpp cfe/trunk/Basic/TargetInfo.cpp cfe/trunk/Basic/Targets.cpp cfe/trunk/CodeGen/CodeGenModule.cpp cfe/trunk/Driver/RewriteTest.cpp cfe/trunk/Driver/TextDiagnosticBuffer.cpp cfe/trunk/Driver/TextDiagnosticBuffer.h cfe/trunk/Driver/TextDiagnosticPrinter.cpp cfe/trunk/Driver/TextDiagnosticPrinter.h cfe/trunk/Driver/TextDiagnostics.cpp cfe/trunk/Driver/TextDiagnostics.h cfe/trunk/Driver/TranslationUnit.cpp cfe/trunk/Driver/clang.cpp cfe/trunk/Lex/LiteralSupport.cpp cfe/trunk/Lex/PPExpressions.cpp cfe/trunk/Lex/Preprocessor.cpp cfe/trunk/Parse/Parser.cpp cfe/trunk/Sema/Sema.cpp cfe/trunk/Sema/SemaDecl.cpp cfe/trunk/Sema/SemaExpr.cpp cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/Basic/Diagnostic.h cfe/trunk/include/clang/Basic/SourceLocation.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Parse/DeclSpec.h Modified: cfe/trunk/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/AST/ASTContext.cpp (original) +++ cfe/trunk/AST/ASTContext.cpp Wed Dec 12 16:39:36 2007 @@ -128,7 +128,7 @@ // C99 6.2.5p2. InitBuiltinType(BoolTy, BuiltinType::Bool); // C99 6.2.5p3. - if (Target.isCharSigned(SourceLocation())) + if (Target.isCharSigned(FullSourceLoc())) InitBuiltinType(CharTy, BuiltinType::Char_S); else InitBuiltinType(CharTy, BuiltinType::Char_U); @@ -213,26 +213,47 @@ default: assert(0 && "Unknown builtin type!"); case BuiltinType::Void: assert(0 && "Incomplete types have no size!"); - case BuiltinType::Bool: Target.getBoolInfo(Size, Align, L); break; + case BuiltinType::Bool: Target.getBoolInfo(Size,Align,getFullLoc(L)); + break; + case BuiltinType::Char_S: case BuiltinType::Char_U: case BuiltinType::UChar: - case BuiltinType::SChar: Target.getCharInfo(Size, Align, L); break; + case BuiltinType::SChar: Target.getCharInfo(Size,Align,getFullLoc(L)); + break; + case BuiltinType::UShort: - case BuiltinType::Short: Target.getShortInfo(Size, Align, L); break; + case BuiltinType::Short: Target.getShortInfo(Size,Align,getFullLoc(L)); + break; + case BuiltinType::UInt: - case BuiltinType::Int: Target.getIntInfo(Size, Align, L); break; + case BuiltinType::Int: Target.getIntInfo(Size,Align,getFullLoc(L)); + break; + case BuiltinType::ULong: - case BuiltinType::Long: Target.getLongInfo(Size, Align, L); break; + case BuiltinType::Long: Target.getLongInfo(Size,Align,getFullLoc(L)); + break; + case BuiltinType::ULongLong: - case BuiltinType::LongLong: Target.getLongLongInfo(Size, Align, L); break; - case BuiltinType::Float: Target.getFloatInfo(Size, Align, F, L); break; - case BuiltinType::Double: Target.getDoubleInfo(Size, Align, F, L);break; - case BuiltinType::LongDouble:Target.getLongDoubleInfo(Size,Align,F,L);break; + case BuiltinType::LongLong: Target.getLongLongInfo(Size,Align, + getFullLoc(L)); + break; + + case BuiltinType::Float: Target.getFloatInfo(Size,Align,F, + getFullLoc(L)); + break; + + case BuiltinType::Double: Target.getDoubleInfo(Size,Align,F, + getFullLoc(L)); + break; + + case BuiltinType::LongDouble: Target.getLongDoubleInfo(Size,Align,F, + getFullLoc(L)); + break; } break; } - case Type::Pointer: Target.getPointerInfo(Size, Align, L); break; + case Type::Pointer: Target.getPointerInfo(Size, Align, getFullLoc(L)); break; case Type::Reference: // "When applied to a reference or a reference type, the result is the size // of the referenced type." C++98 5.3.3p2: expr.sizeof. Modified: cfe/trunk/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/AST/Expr.cpp (original) +++ cfe/trunk/AST/Expr.cpp Wed Dec 12 16:39:36 2007 @@ -625,7 +625,9 @@ Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType(), Exp->getOperatorLoc()); } else { - unsigned CharSize = Ctx.Target.getCharWidth(Exp->getOperatorLoc()); + unsigned CharSize = + Ctx.Target.getCharWidth(Ctx.getFullLoc(Exp->getOperatorLoc())); + Result = Ctx.getTypeSize(Exp->getSubExpr()->getType(), Exp->getOperatorLoc()) / CharSize; } Modified: cfe/trunk/Analysis/DeadStores.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/DeadStores.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Analysis/DeadStores.cpp (original) +++ cfe/trunk/Analysis/DeadStores.cpp Wed Dec 12 16:39:36 2007 @@ -40,8 +40,8 @@ if (VarDecl* VD = dyn_cast(DR->getDecl())) if (VD->hasLocalStorage() && !Live(VD,AD)) { SourceRange R = B->getRHS()->getSourceRange(); - Diags.Report(DR->getSourceRange().getBegin(), diag::warn_dead_store, - Ctx.getSourceManager(), 0, 0, &R, 1); + Diags.Report(Ctx.getFullLoc(DR->getSourceRange().getBegin()), + diag::warn_dead_store, 0, 0, &R, 1); } } else if(DeclStmt* DS = dyn_cast(S)) @@ -62,8 +62,8 @@ if (!E->isConstantExpr(Ctx,NULL)) { // Flag a warning. SourceRange R = E->getSourceRange(); - Diags.Report(V->getLocation(), diag::warn_dead_store, - Ctx.getSourceManager(), 0, 0, &R, 1); + Diags.Report(Ctx.getFullLoc(V->getLocation()), + diag::warn_dead_store, 0, 0, &R, 1); } } } Modified: cfe/trunk/Analysis/UninitializedValues.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/UninitializedValues.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Analysis/UninitializedValues.cpp (original) +++ cfe/trunk/Analysis/UninitializedValues.cpp Wed Dec 12 16:39:36 2007 @@ -222,8 +222,8 @@ if (V(VD,AD) == Uninitialized) if (AlreadyWarned.insert(VD)) - Diags.Report(DR->getSourceRange().getBegin(), diag::warn_uninit_val, - Ctx.getSourceManager()); + Diags.Report(Ctx.getFullLoc(DR->getSourceRange().getBegin()), + diag::warn_uninit_val); } }; } // end anonymous namespace Modified: cfe/trunk/Basic/Diagnostic.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/Diagnostic.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Basic/Diagnostic.cpp (original) +++ cfe/trunk/Basic/Diagnostic.cpp Wed Dec 12 16:39:36 2007 @@ -197,8 +197,7 @@ /// Report - Issue the message to the client. If the client wants us to stop /// compilation, return true, otherwise return false. DiagID is a member of /// the diag::kind enum. -void Diagnostic::Report(SourceLocation Pos, unsigned DiagID, - SourceManager* SrcMgr, +void Diagnostic::Report(FullSourceLoc Pos, unsigned DiagID, const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, unsigned NumRanges) { // Figure out the diagnostic level of this message. @@ -214,11 +213,11 @@ } // Are we going to ignore this diagnosic? - if (Client.IgnoreDiagnostic(DiagLevel, Pos, SrcMgr)) + if (Client.IgnoreDiagnostic(DiagLevel, Pos)) return; // Finally, report it. - Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID, SrcMgr, + Client.HandleDiagnostic(*this, DiagLevel, Pos, (diag::kind)DiagID, Strs, NumStrs, Ranges, NumRanges); ++NumDiagnostics; } Modified: cfe/trunk/Basic/SourceLocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/SourceLocation.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Basic/SourceLocation.cpp (original) +++ cfe/trunk/Basic/SourceLocation.cpp Wed Dec 12 16:39:36 2007 @@ -8,10 +8,12 @@ //===----------------------------------------------------------------------===// // // This file defines serialization methods for the SourceLocation class. +// This file defines accessor methods for the FullSourceLoc class. // //===----------------------------------------------------------------------===// #include "clang/Basic/SourceLocation.h" +#include "clang/Basic/SourceManager.h" #include "llvm/Bitcode/Serialize.h" #include "llvm/Bitcode/Deserialize.h" @@ -35,3 +37,43 @@ SourceLocation B = SourceLocation::ReadVal(D); return SourceRange(A,B); } + +FullSourceLoc FullSourceLoc::getLogicalLoc() { + assert (isValid()); + return FullSourceLoc(SrcMgr->getLogicalLoc(Loc),*SrcMgr); +} + +FullSourceLoc FullSourceLoc::getIncludeLoc() { + assert (isValid()); + return FullSourceLoc(SrcMgr->getIncludeLoc(Loc),*SrcMgr); +} + +unsigned FullSourceLoc::getLineNumber() { + assert (isValid()); + return SrcMgr->getLineNumber(Loc); +} + +unsigned FullSourceLoc::getColumnNumber() { + assert (isValid()); + return SrcMgr->getColumnNumber(Loc); +} + +const char* FullSourceLoc::getSourceName() const { + assert (isValid()); + return SrcMgr->getSourceName(Loc); +} + +const FileEntry* FullSourceLoc::getFileEntryForLoc() const { + assert (isValid()); + return SrcMgr->getFileEntryForLoc(Loc); +} + +const char * FullSourceLoc::getCharacterData() const { + assert (isValid()); + return SrcMgr->getCharacterData(Loc); +} + +const llvm::MemoryBuffer* FullSourceLoc::getBuffer() const { + assert (isValid()); + return SrcMgr->getBuffer(Loc.getFileID()); +} Modified: cfe/trunk/Basic/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/TargetInfo.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Basic/TargetInfo.cpp (original) +++ cfe/trunk/Basic/TargetInfo.cpp Wed Dec 12 16:39:36 2007 @@ -29,20 +29,20 @@ void TargetInfo::getFloatInfo(uint64_t &Size, unsigned &Align, const llvm::fltSemantics *&Format, - SourceLocation Loc) { + FullSourceLoc Loc) { Align = 32; // FIXME: implement correctly. Size = 32; Format = &llvm::APFloat::IEEEsingle; } void TargetInfo::getDoubleInfo(uint64_t &Size, unsigned &Align, const llvm::fltSemantics *&Format, - SourceLocation Loc) { + FullSourceLoc Loc) { Size = Align = 64; // FIXME: implement correctly. Format = &llvm::APFloat::IEEEdouble; } void TargetInfo::getLongDoubleInfo(uint64_t &Size, unsigned &Align, const llvm::fltSemantics *&Format, - SourceLocation Loc) { + FullSourceLoc Loc) { Size = Align = 64; // FIXME: implement correctly. Format = &llvm::APFloat::IEEEdouble; //Size = 80; Align = 32; // FIXME: implement correctly. @@ -63,9 +63,10 @@ /// DiagnoseNonPortability - When a use of a non-portable target feature is /// used, this method emits the diagnostic and marks the translation unit as /// non-portable. -void TargetInfo::DiagnoseNonPortability(SourceLocation Loc, unsigned DiagKind) { +void TargetInfo::DiagnoseNonPortability(FullSourceLoc Loc, + unsigned DiagKind) { NonPortable = true; - if (Diag && Loc.isValid()) Diag->Report(Loc, DiagKind, SrcMgr); + if (Diag && Loc.isValid()) Diag->Report(Loc, DiagKind); } /// GetTargetDefineMap - Get the set of target #defines in an associative @@ -196,7 +197,7 @@ /// ComputeWCharWidth - Determine the width of the wchar_t type for the primary /// target, diagnosing whether this is non-portable across the secondary /// targets. -void TargetInfo::ComputeWCharInfo(SourceLocation Loc) { +void TargetInfo::ComputeWCharInfo(FullSourceLoc Loc) { PrimaryTarget->getWCharInfo(WCharWidth, WCharAlign); // Check whether this is portable across the secondary targets if the T-U is Modified: cfe/trunk/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/Targets.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Basic/Targets.cpp (original) +++ cfe/trunk/Basic/Targets.cpp Wed Dec 12 16:39:36 2007 @@ -699,8 +699,7 @@ /// CreateTargetInfo - Return the set of target info objects as specified by /// the -arch command line option. -TargetInfo* TargetInfo::CreateTargetInfo(SourceManager& SrcMgr, - const std::string* TriplesStart, +TargetInfo* TargetInfo::CreateTargetInfo(const std::string* TriplesStart, const std::string* TriplesEnd, Diagnostic *Diags) { @@ -710,7 +709,7 @@ if (!PrimaryTarget) return NULL; - TargetInfo *TI = new TargetInfo(SrcMgr, PrimaryTarget, Diags); + TargetInfo *TI = new TargetInfo(PrimaryTarget, Diags); // Add all secondary targets. for (const std::string* I=TriplesStart+1; I != TriplesEnd; ++I) { Modified: cfe/trunk/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/CodeGen/CodeGenModule.cpp Wed Dec 12 16:39:36 2007 @@ -40,7 +40,7 @@ "cannot codegen this %0 yet"); SourceRange Range = S->getSourceRange(); std::string Msg = Type; - getDiags().Report(S->getLocStart(), DiagID, Context.getSourceManager(), + getDiags().Report(Context.getFullLoc(S->getLocStart()), DiagID, &Msg, 1, &Range, 1); } @@ -559,7 +559,7 @@ if (MemCpyFn) return MemCpyFn; llvm::Intrinsic::ID IID; uint64_t Size; unsigned Align; - Context.Target.getPointerInfo(Size, Align, SourceLocation()); + Context.Target.getPointerInfo(Size, Align, FullSourceLoc()); switch (Size) { default: assert(0 && "Unknown ptr width"); case 32: IID = llvm::Intrinsic::memcpy_i32; break; Modified: cfe/trunk/Driver/RewriteTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/RewriteTest.cpp (original) +++ cfe/trunk/Driver/RewriteTest.cpp Wed Dec 12 16:39:36 2007 @@ -911,8 +911,7 @@ unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error, "rewriter could not replace sub-expression due to macros"); SourceRange Range = Exp->getSourceRange(); - Diags.Report(Exp->getAtLoc(), DiagID, Context->getSourceManager(), - 0, 0, &Range, 1); + Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1); delete Replacement; return Exp; } Modified: cfe/trunk/Driver/TextDiagnosticBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticBuffer.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/TextDiagnosticBuffer.cpp (original) +++ cfe/trunk/Driver/TextDiagnosticBuffer.cpp Wed Dec 12 16:39:36 2007 @@ -19,9 +19,8 @@ /// void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level Level, - SourceLocation Pos, + FullSourceLoc Pos, diag::kind ID, - SourceManager* SrcMgr, const std::string *Strs, unsigned NumStrs, const SourceRange *, @@ -29,12 +28,14 @@ switch (Level) { default: assert(0 && "Diagnostic not handled during diagnostic buffering!"); case Diagnostic::Warning: - Warnings.push_back(std::make_pair(Pos, FormatDiagnostic(Diags, Level, ID, - Strs, NumStrs))); + Warnings.push_back(std::make_pair(Pos.getLocation(), + FormatDiagnostic(Diags, Level, ID, + Strs, NumStrs))); break; case Diagnostic::Error: - Errors.push_back(std::make_pair(Pos, FormatDiagnostic(Diags, Level, ID, - Strs, NumStrs))); + Errors.push_back(std::make_pair(Pos.getLocation(), + FormatDiagnostic(Diags, Level, ID, + Strs, NumStrs))); break; } } Modified: cfe/trunk/Driver/TextDiagnosticBuffer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticBuffer.h?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/TextDiagnosticBuffer.h (original) +++ cfe/trunk/Driver/TextDiagnosticBuffer.h Wed Dec 12 16:39:36 2007 @@ -38,10 +38,10 @@ const_iterator warn_begin() const { return Warnings.begin(); } const_iterator warn_end() const { return Warnings.end(); } - virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel, - SourceLocation Pos, + virtual void HandleDiagnostic(Diagnostic &Diags, + Diagnostic::Level DiagLevel, + FullSourceLoc Pos, diag::kind ID, - SourceManager* SrcMgr, const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, Modified: cfe/trunk/Driver/TextDiagnosticPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticPrinter.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/TextDiagnosticPrinter.cpp (original) +++ cfe/trunk/Driver/TextDiagnosticPrinter.cpp Wed Dec 12 16:39:36 2007 @@ -31,23 +31,23 @@ " diagnostics")); void TextDiagnosticPrinter:: -PrintIncludeStack(SourceLocation Pos, SourceManager& SourceMgr) { +PrintIncludeStack(FullSourceLoc Pos) { if (Pos.isInvalid()) return; - Pos = SourceMgr.getLogicalLoc(Pos); + Pos = Pos.getLogicalLoc(); // Print out the other include frames first. - PrintIncludeStack(SourceMgr.getIncludeLoc(Pos),SourceMgr); - unsigned LineNo = SourceMgr.getLineNumber(Pos); + PrintIncludeStack(Pos.getIncludeLoc()); + unsigned LineNo = Pos.getLineNumber(); - std::cerr << "In file included from " << SourceMgr.getSourceName(Pos) + std::cerr << "In file included from " << Pos.getSourceName() << ":" << LineNo << ":\n"; } /// HighlightRange - Given a SourceRange and a line number, highlight (with ~'s) /// any characters in LineNo that intersect the SourceRange. void TextDiagnosticPrinter::HighlightRange(const SourceRange &R, - SourceManager* SourceMgr, + SourceManager& SourceMgr, unsigned LineNo, std::string &CaratLine, const std::string &SourceLine) { @@ -55,16 +55,16 @@ "Expect a correspondence between source and carat line!"); if (!R.isValid()) return; - unsigned StartLineNo = SourceMgr->getLogicalLineNumber(R.getBegin()); + unsigned StartLineNo = SourceMgr.getLogicalLineNumber(R.getBegin()); if (StartLineNo > LineNo) return; // No intersection. - unsigned EndLineNo = SourceMgr->getLogicalLineNumber(R.getEnd()); + unsigned EndLineNo = SourceMgr.getLogicalLineNumber(R.getEnd()); if (EndLineNo < LineNo) return; // No intersection. // Compute the column number of the start. unsigned StartColNo = 0; if (StartLineNo == LineNo) { - StartColNo = SourceMgr->getLogicalColumnNumber(R.getBegin()); + StartColNo = SourceMgr.getLogicalColumnNumber(R.getBegin()); if (StartColNo) --StartColNo; // Zero base the col #. } @@ -76,12 +76,12 @@ // Compute the column number of the end. unsigned EndColNo = CaratLine.size(); if (EndLineNo == LineNo) { - EndColNo = SourceMgr->getLogicalColumnNumber(R.getEnd()); + EndColNo = SourceMgr.getLogicalColumnNumber(R.getEnd()); if (EndColNo) { --EndColNo; // Zero base the col #. // Add in the length of the token, so that we cover multi-char tokens. - EndColNo += Lexer::MeasureTokenLength(R.getEnd(), *SourceMgr); + EndColNo += Lexer::MeasureTokenLength(R.getEnd(), SourceMgr); } else { EndColNo = CaratLine.size(); } @@ -100,9 +100,8 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level Level, - SourceLocation Pos, + FullSourceLoc Pos, diag::kind ID, - SourceManager* SourceMgr, const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, @@ -111,25 +110,25 @@ const char *LineStart = 0, *LineEnd = 0; if (Pos.isValid()) { - SourceLocation LPos = SourceMgr->getLogicalLoc(Pos); - LineNo = SourceMgr->getLineNumber(LPos); + FullSourceLoc LPos = Pos.getLogicalLoc(); + LineNo = LPos.getLineNumber(); // First, if this diagnostic is not in the main file, print out the // "included from" lines. - if (LastWarningLoc != SourceMgr->getIncludeLoc(LPos)) { - LastWarningLoc = SourceMgr->getIncludeLoc(LPos); - PrintIncludeStack(LastWarningLoc,*SourceMgr); + if (LastWarningLoc != LPos.getIncludeLoc()) { + LastWarningLoc = LPos.getIncludeLoc(); + PrintIncludeStack(LastWarningLoc); } // Compute the column number. Rewind from the current position to the start // of the line. - ColNo = SourceMgr->getColumnNumber(LPos); - const char *TokLogicalPtr = SourceMgr->getCharacterData(LPos); + ColNo = LPos.getColumnNumber(); + const char *TokLogicalPtr = LPos.getCharacterData(); LineStart = TokLogicalPtr-ColNo+1; // Column # is 1-based // Compute the line end. Scan forward from the error position to the end of // the line. - const llvm::MemoryBuffer *Buffer = SourceMgr->getBuffer(LPos.getFileID()); + const llvm::MemoryBuffer *Buffer = LPos.getBuffer(); const char *BufEnd = Buffer->getBufferEnd(); LineEnd = TokLogicalPtr; while (LineEnd != BufEnd && @@ -164,7 +163,7 @@ // Highlight all of the characters covered by Ranges with ~ characters. for (unsigned i = 0; i != NumRanges; ++i) - HighlightRange(Ranges[i], SourceMgr, LineNo, CaratLine, SourceLine); + HighlightRange(Ranges[i], Pos.getManager(),LineNo, CaratLine, SourceLine); // Next, insert the carat itself. if (ColNo-1 < CaratLine.size()) Modified: cfe/trunk/Driver/TextDiagnosticPrinter.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnosticPrinter.h?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/TextDiagnosticPrinter.h (original) +++ cfe/trunk/Driver/TextDiagnosticPrinter.h Wed Dec 12 16:39:36 2007 @@ -22,21 +22,22 @@ class SourceManager; class TextDiagnosticPrinter : public TextDiagnostics { - SourceLocation LastWarningLoc; + FullSourceLoc LastWarningLoc; public: TextDiagnosticPrinter() {} - void PrintIncludeStack(SourceLocation Pos, SourceManager& SrcMgr); + void PrintIncludeStack(FullSourceLoc Pos); + void HighlightRange(const SourceRange &R, - SourceManager* SrcMgr, + SourceManager& SrcMgr, unsigned LineNo, std::string &CaratLine, const std::string &SourceLine); - virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel, - SourceLocation Pos, + virtual void HandleDiagnostic(Diagnostic &Diags, + Diagnostic::Level DiagLevel, + FullSourceLoc Pos, diag::kind ID, - SourceManager* SrcMgr, const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, Modified: cfe/trunk/Driver/TextDiagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnostics.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/TextDiagnostics.cpp (original) +++ cfe/trunk/Driver/TextDiagnostics.cpp Wed Dec 12 16:39:36 2007 @@ -40,13 +40,12 @@ } bool TextDiagnostics::IgnoreDiagnostic(Diagnostic::Level Level, - SourceLocation Pos, - SourceManager* SourceMgr) { + FullSourceLoc Pos) { if (Pos.isValid()) { // If this is a warning or note, and if it a system header, suppress the // diagnostic. if (Level == Diagnostic::Warning || Level == Diagnostic::Note) { - if (const FileEntry *F = SourceMgr->getFileEntryForLoc(Pos)) { + if (const FileEntry *F = Pos.getFileEntryForLoc()) { DirectoryLookup::DirType DirInfo = TheHeaderSearch->getFileDirFlavor(F); if (DirInfo == DirectoryLookup::SystemHeaderDir || DirInfo == DirectoryLookup::ExternCSystemHeaderDir) Modified: cfe/trunk/Driver/TextDiagnostics.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TextDiagnostics.h?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/TextDiagnostics.h (original) +++ cfe/trunk/Driver/TextDiagnostics.h Wed Dec 12 16:39:36 2007 @@ -35,13 +35,11 @@ void setHeaderSearch(HeaderSearch &HS) { TheHeaderSearch = &HS; } virtual bool IgnoreDiagnostic(Diagnostic::Level Level, - SourceLocation Pos, - SourceManager* SrcMgr); + FullSourceLoc Pos); virtual void HandleDiagnostic(Diagnostic &Diags, Diagnostic::Level DiagLevel, - SourceLocation Pos, + FullSourceLoc Pos, diag::kind ID, - SourceManager* SrcMgr, const std::string *Strs, unsigned NumStrs, const SourceRange *Ranges, Modified: cfe/trunk/Driver/TranslationUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TranslationUnit.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/TranslationUnit.cpp (original) +++ cfe/trunk/Driver/TranslationUnit.cpp Wed Dec 12 16:39:36 2007 @@ -184,7 +184,7 @@ assert (FoundBlock); // Read the SourceManager. - SourceManager& SrcMgr = *SourceManager::CreateAndRegister(Dezr,FMgr); + SourceManager::CreateAndRegister(Dezr,FMgr); // Read the LangOptions. TU->LangOpts.Read(Dezr); @@ -193,8 +193,7 @@ llvm::SerializedPtrID PtrID = Dezr.ReadPtrID(); char* triple = Dezr.ReadCStr(NULL,0,true); std::string Triple(triple); - Dezr.RegisterPtr(PtrID,TargetInfo::CreateTargetInfo(SrcMgr, - &Triple, + Dezr.RegisterPtr(PtrID,TargetInfo::CreateTargetInfo(&Triple, &Triple+1)); delete [] triple; } Modified: cfe/trunk/Driver/clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Driver/clang.cpp (original) +++ cfe/trunk/Driver/clang.cpp Wed Dec 12 16:39:36 2007 @@ -1019,8 +1019,7 @@ // Create triples, and create the TargetInfo. std::vector triples; CreateTargetTriples(triples); - Target = TargetInfo::CreateTargetInfo(SourceMgr, - &triples[0], + Target = TargetInfo::CreateTargetInfo(&triples[0], &triples[0]+triples.size(), &Diags); Modified: cfe/trunk/Lex/LiteralSupport.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/LiteralSupport.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Lex/LiteralSupport.cpp (original) +++ cfe/trunk/Lex/LiteralSupport.cpp Wed Dec 12 16:39:36 2007 @@ -93,8 +93,10 @@ } // See if any bits will be truncated when evaluated as a character. - unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc) - : PP.getTargetInfo().getCharWidth(Loc); + unsigned CharWidth = IsWide + ? PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc)) + : PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc)); + if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) { Overflow = true; ResultChar &= ~0U >> (32-CharWidth); @@ -122,8 +124,10 @@ ThisTokBuf[0] >= '0' && ThisTokBuf[0] <= '7'); // Check for overflow. Reject '\777', but not L'\777'. - unsigned CharWidth = IsWide ? PP.getTargetInfo().getWCharWidth(Loc) - : PP.getTargetInfo().getCharWidth(Loc); + unsigned CharWidth = IsWide + ? PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc)) + : PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc)); + if (CharWidth != 32 && (ResultChar >> CharWidth) != 0) { PP.Diag(Loc, diag::warn_octal_escape_too_large); ResultChar &= ~0U >> (32-CharWidth); @@ -453,13 +457,13 @@ // FIXME: This assumes that 'int' is 32-bits in overflow calculation, and the // size of "value". - assert(PP.getTargetInfo().getIntWidth(Loc) == 32 && + assert(PP.getTargetInfo().getIntWidth(PP.getFullLoc(Loc)) == 32 && "Assumes sizeof(int) == 4 for now"); // FIXME: This assumes that wchar_t is 32-bits for now. - assert(PP.getTargetInfo().getWCharWidth(Loc) == 32 && + assert(PP.getTargetInfo().getWCharWidth(PP.getFullLoc(Loc)) == 32 && "Assumes sizeof(wchar_t) == 4 for now"); // FIXME: This extensively assumes that 'char' is 8-bits. - assert(PP.getTargetInfo().getCharWidth(Loc) == 8 && + assert(PP.getTargetInfo().getCharWidth(PP.getFullLoc(Loc)) == 8 && "Assumes char is 8 bits"); bool isFirstChar = true; @@ -505,7 +509,7 @@ // character constants are not sign extended in the this implementation: // '\xFF\xFF' = 65536 and '\x0\xFF' = 255, which matches GCC. if (!IsWide && !isMultiChar && (Value & 128) && - PP.getTargetInfo().isCharSigned(Loc)) + PP.getTargetInfo().isCharSigned(PP.getFullLoc(Loc))) Value = (signed char)Value; } @@ -583,7 +587,9 @@ // query the target. As such, wchar_tByteWidth is only valid if AnyWide=true. wchar_tByteWidth = ~0U; if (AnyWide) { - wchar_tByteWidth = Target.getWCharWidth(StringToks[0].getLocation()); + wchar_tByteWidth = + Target.getWCharWidth(PP.getFullLoc(StringToks[0].getLocation())); + assert((wchar_tByteWidth & 7) == 0 && "Assumes wchar_t is byte multiple!"); wchar_tByteWidth /= 8; } Modified: cfe/trunk/Lex/PPExpressions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/PPExpressions.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Lex/PPExpressions.cpp (original) +++ cfe/trunk/Lex/PPExpressions.cpp Wed Dec 12 16:39:36 2007 @@ -112,15 +112,17 @@ if (Macro->isTargetSpecific()) { // Don't warn on second use. Macro->setIsTargetSpecific(false); - PP.getTargetInfo().DiagnoseNonPortability(PeekTok.getLocation(), - diag::port_target_macro_use); + PP.getTargetInfo().DiagnoseNonPortability( + PP.getFullLoc(PeekTok.getLocation()), + diag::port_target_macro_use); } } else if (ValueLive) { // Use of a target-specific macro for some other target? If so, warn. if (II->isOtherTargetMacro()) { II->setIsOtherTargetMacro(false); // Don't warn on second use. - PP.getTargetInfo().DiagnoseNonPortability(PeekTok.getLocation(), - diag::port_target_macro_use); + PP.getTargetInfo().DiagnoseNonPortability( + PP.getFullLoc(PeekTok.getLocation()), + diag::port_target_macro_use); } } @@ -211,16 +213,16 @@ TargetInfo &TI = PP.getTargetInfo(); unsigned NumBits; if (Literal.isWide()) - NumBits = TI.getWCharWidth(PeekTok.getLocation()); + NumBits = TI.getWCharWidth(PP.getFullLoc(PeekTok.getLocation())); else - NumBits = TI.getCharWidth(PeekTok.getLocation()); + NumBits = TI.getCharWidth(PP.getFullLoc(PeekTok.getLocation())); // Set the width. llvm::APSInt Val(NumBits); // Set the value. Val = Literal.getValue(); // Set the signedness. - Val.setIsUnsigned(!TI.isCharSigned(PeekTok.getLocation())); + Val.setIsUnsigned(!TI.isCharSigned(PP.getFullLoc(PeekTok.getLocation()))); if (Result.getBitWidth() > Val.getBitWidth()) { if (Val.isSigned()) @@ -617,7 +619,9 @@ Lex(Tok); // C99 6.10.1p3 - All expressions are evaluated as intmax_t or uintmax_t. - unsigned BitWidth = getTargetInfo().getIntMaxTWidth(Tok.getLocation()); + unsigned BitWidth = + getTargetInfo().getIntMaxTWidth(getFullLoc(Tok.getLocation())); + llvm::APSInt ResVal(BitWidth); DefinedTracker DT; if (EvaluateValue(ResVal, Tok, DT, true, *this)) { Modified: cfe/trunk/Lex/Preprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Lex/Preprocessor.cpp (original) +++ cfe/trunk/Lex/Preprocessor.cpp Wed Dec 12 16:39:36 2007 @@ -120,12 +120,12 @@ /// the specified Token's location, translating the token's start /// position in the current buffer into a SourcePosition object for rendering. void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID) { - Diags.Report(Loc, DiagID, SourceMgr); + Diags.Report(getFullLoc(Loc), DiagID); } void Preprocessor::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) { - Diags.Report(Loc, DiagID, SourceMgr, &Msg, 1); + Diags.Report(getFullLoc(Loc), DiagID, &Msg, 1); } void Preprocessor::DumpToken(const Token &Tok, bool DumpFlags) const { @@ -791,7 +791,7 @@ // If this is the first use of a target-specific macro, warn about it. if (MI->isTargetSpecific()) { MI->setIsTargetSpecific(false); // Don't warn on second use. - getTargetInfo().DiagnoseNonPortability(Identifier.getLocation(), + getTargetInfo().DiagnoseNonPortability(getFullLoc(Identifier.getLocation()), diag::port_target_macro_use); } @@ -1227,7 +1227,7 @@ // This diagnosic is only emitted when macro expansion is enabled, because // the macro would not have been expanded for the other target either. II.setIsOtherTargetMacro(false); // Don't warn on second use. - getTargetInfo().DiagnoseNonPortability(Identifier.getLocation(), + getTargetInfo().DiagnoseNonPortability(getFullLoc(Identifier.getLocation()), diag::port_target_macro_use); } @@ -2337,15 +2337,17 @@ // If this is the first use of a target-specific macro, warn about it. if (MI->isTargetSpecific()) { MI->setIsTargetSpecific(false); // Don't warn on second use. - getTargetInfo().DiagnoseNonPortability(MacroNameTok.getLocation(), - diag::port_target_macro_use); + getTargetInfo().DiagnoseNonPortability( + getFullLoc(MacroNameTok.getLocation()), + diag::port_target_macro_use); } } else { // Use of a target-specific macro for some other target? If so, warn. if (MII->isOtherTargetMacro()) { MII->setIsOtherTargetMacro(false); // Don't warn on second use. - getTargetInfo().DiagnoseNonPortability(MacroNameTok.getLocation(), - diag::port_target_macro_use); + getTargetInfo().DiagnoseNonPortability( + getFullLoc(MacroNameTok.getLocation()), + diag::port_target_macro_use); } } Modified: cfe/trunk/Parse/Parser.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/Parser.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Parse/Parser.cpp (original) +++ cfe/trunk/Parse/Parser.cpp Wed Dec 12 16:39:36 2007 @@ -31,7 +31,7 @@ void Parser::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) { - Diags.Report(Loc, DiagID, PP.getSourceManager(), &Msg, 1); + Diags.Report(FullSourceLoc(Loc,PP.getSourceManager()), DiagID, &Msg, 1); } /// MatchRHSPunctuation - For punctuation with a LHS and RHS (e.g. '['/']'), Modified: cfe/trunk/Sema/Sema.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Sema/Sema.cpp (original) +++ cfe/trunk/Sema/Sema.cpp Wed Dec 12 16:39:36 2007 @@ -118,54 +118,51 @@ //===----------------------------------------------------------------------===// bool Sema::Diag(SourceLocation Loc, unsigned DiagID) { - PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager()); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) { - PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), &Msg, 1); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, const std::string &Msg2) { std::string MsgArr[] = { Msg1, Msg2 }; - PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), MsgArr, 2); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, SourceRange Range) { - PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), 0,0, &Range,1); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, 0, 0, &Range,1); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, SourceRange Range) { - PP.getDiagnostics().Report(Loc,DiagID,PP.getSourceManager(),&Msg,1,&Range,1); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, &Range,1); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1, const std::string &Msg2, SourceRange Range) { std::string MsgArr[] = { Msg1, Msg2 }; - PP.getDiagnostics().Report(Loc,DiagID,PP.getSourceManager(), - MsgArr,2,&Range,1); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, MsgArr, 2, &Range, 1); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, SourceRange R1, SourceRange R2) { SourceRange RangeArr[] = { R1, R2 }; - PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), - 0, 0, RangeArr, 2); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, 0, 0, RangeArr, 2); return true; } bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg, SourceRange R1, SourceRange R2) { SourceRange RangeArr[] = { R1, R2 }; - PP.getDiagnostics().Report(Loc, DiagID, PP.getSourceManager(), &Msg, - 1, RangeArr, 2); + PP.getDiagnostics().Report(PP.getFullLoc(Loc), DiagID, &Msg, 1, RangeArr, 2); return true; } @@ -173,8 +170,7 @@ const std::string &Msg2, SourceRange R1, SourceRange R2) { std::string MsgArr[] = { Msg1, Msg2 }; SourceRange RangeArr[] = { R1, R2 }; - PP.getDiagnostics().Report(Range, DiagID, PP.getSourceManager(), MsgArr, 2, - RangeArr, 2); + PP.getDiagnostics().Report(PP.getFullLoc(Range),DiagID, MsgArr,2,RangeArr, 2); return true; } Modified: cfe/trunk/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Sema/SemaDecl.cpp (original) +++ cfe/trunk/Sema/SemaDecl.cpp Wed Dec 12 16:39:36 2007 @@ -135,7 +135,7 @@ if (II->isNonPortableBuiltin()) { // Only emit this diagnostic once for this builtin. II->setNonPortableBuiltin(false); - Context.Target.DiagnoseNonPortability(IdLoc, + Context.Target.DiagnoseNonPortability(Context.getFullLoc(IdLoc), diag::port_target_builtin_use); } // If this is a builtin on this (or all) targets, create the decl. @@ -1506,7 +1506,8 @@ // TODO: If the result value doesn't fit in an int, it must be a long or long // long value. ISO C does not support this, but GCC does as an extension, // emit a warning. - unsigned IntWidth = Context.Target.getIntWidth(Enum->getLocation()); + unsigned IntWidth = + Context.Target.getIntWidth(Context.getFullLoc(Enum->getLocation())); // Verify that all the values are okay, compute the size of the values, and @@ -1562,11 +1563,15 @@ BestType = Context.IntTy; BestWidth = IntWidth; } else { - BestWidth = Context.Target.getLongWidth(Enum->getLocation()); + BestWidth = + Context.Target.getLongWidth(Context.getFullLoc(Enum->getLocation())); + if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) BestType = Context.LongTy; else { - BestWidth = Context.Target.getLongLongWidth(Enum->getLocation()); + BestWidth = Context.Target.getLongLongWidth( + Context.getFullLoc(Enum->getLocation())); + if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth) Diag(Enum->getLocation(), diag::warn_enum_too_large); BestType = Context.LongLongTy; @@ -1579,10 +1584,14 @@ BestType = Context.UnsignedIntTy; BestWidth = IntWidth; } else if (NumPositiveBits <= - (BestWidth = Context.Target.getLongWidth(Enum->getLocation()))) + (BestWidth = Context.Target.getLongWidth( + Context.getFullLoc(Enum->getLocation())))) + BestType = Context.UnsignedLongTy; else { - BestWidth = Context.Target.getLongLongWidth(Enum->getLocation()); + BestWidth = + Context.Target.getLongLongWidth(Context.getFullLoc(Enum->getLocation())); + assert(NumPositiveBits <= BestWidth && "How could an initializer get larger than ULL?"); BestType = Context.UnsignedLongLongTy; Modified: cfe/trunk/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/Sema/SemaExpr.cpp (original) +++ cfe/trunk/Sema/SemaExpr.cpp Wed Dec 12 16:39:36 2007 @@ -181,13 +181,17 @@ if (Literal.isFloat) { Ty = Context.FloatTy; - Context.Target.getFloatInfo(Size, Align, Format, Tok.getLocation()); + Context.Target.getFloatInfo(Size, Align, Format, + Context.getFullLoc(Tok.getLocation())); + } else if (Literal.isLong) { Ty = Context.LongDoubleTy; - Context.Target.getLongDoubleInfo(Size, Align, Format, Tok.getLocation()); + Context.Target.getLongDoubleInfo(Size, Align, Format, + Context.getFullLoc(Tok.getLocation())); } else { Ty = Context.DoubleTy; - Context.Target.getDoubleInfo(Size, Align, Format, Tok.getLocation()); + Context.Target.getDoubleInfo(Size, Align, Format, + Context.getFullLoc(Tok.getLocation())); } // isExact will be set by GetFloatValue(). @@ -207,7 +211,8 @@ Diag(Tok.getLocation(), diag::ext_longlong); // Get the value in the widest-possible width. - llvm::APInt ResultVal(Context.Target.getIntMaxTWidth(Tok.getLocation()), 0); + llvm::APInt ResultVal(Context.Target.getIntMaxTWidth( + Context.getFullLoc(Tok.getLocation())), 0); if (Literal.GetIntegerValue(ResultVal)) { // If this value didn't fit into uintmax_t, warn and force to ull. Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Dec 12 16:39:36 2007 @@ -77,6 +77,10 @@ SelectorTable &Selectors; SourceManager& getSourceManager() { return SourceMgr; } + + FullSourceLoc getFullLoc(SourceLocation Loc) const { + return FullSourceLoc(Loc,SourceMgr); + } /// This is intentionally not serialized. It is populated by the /// ASTContext ctor, and there are no external pointers/references to Modified: cfe/trunk/include/clang/Basic/Diagnostic.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/Diagnostic.h (original) +++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Dec 12 16:39:36 2007 @@ -147,25 +147,17 @@ /// Report - Issue the message to the client. DiagID is a member of the /// diag::kind enum. - void Report(SourceLocation Pos, unsigned DiagID, SourceManager& SrcMgr, + void Report(FullSourceLoc Pos, unsigned DiagID, const std::string *Strs = 0, unsigned NumStrs = 0, - const SourceRange *Ranges = 0, unsigned NumRanges = 0) { - Report(Pos,DiagID,&SrcMgr,Strs,NumStrs,Ranges,NumRanges); - } - + const SourceRange *Ranges = 0, unsigned NumRanges = 0); /// Report - Issue the message to the client. DiagID is a member of the /// diag::kind enum. - void Report(unsigned DiagID, const std::string *Strs = 0, - unsigned NumStrs = 0, const SourceRange *Ranges = 0, - unsigned NumRanges = 0) { - Report(SourceLocation(),DiagID,NULL,Strs,NumStrs,Ranges,NumRanges); + void Report(unsigned DiagID, + const std::string *Strs = 0, unsigned NumStrs = 0, + const SourceRange *Ranges = 0, unsigned NumRanges = 0) { + Report(FullSourceLoc(),DiagID,Strs,NumStrs,Ranges,NumRanges); } - -private: - void Report(SourceLocation Pos, unsigned DiagID, SourceManager* SrcMgr, - const std::string *Strs, unsigned NumStrs, - const SourceRange *Ranges, unsigned NumRanges); }; /// DiagnosticClient - This is an abstract interface implemented by clients of @@ -177,16 +169,17 @@ /// IgnoreDiagnostic - If the client wants to ignore this diagnostic, then /// return true. virtual bool IgnoreDiagnostic(Diagnostic::Level DiagLevel, - SourceLocation Pos, - SourceManager* SrcMgr) = 0; + FullSourceLoc Pos) = 0; /// HandleDiagnostic - Handle this diagnostic, reporting it to the user or /// capturing it to a log as needed. virtual void HandleDiagnostic(Diagnostic &Diags, - Diagnostic::Level DiagLevel, SourceLocation Pos, - diag::kind ID, SourceManager* SrcMgr, + Diagnostic::Level DiagLevel, + FullSourceLoc Pos, + diag::kind ID, const std::string *Strs, - unsigned NumStrs, const SourceRange *Ranges, + unsigned NumStrs, + const SourceRange *Ranges, unsigned NumRanges) = 0; }; Modified: cfe/trunk/include/clang/Basic/SourceLocation.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceLocation.h?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/SourceLocation.h (original) +++ cfe/trunk/include/clang/Basic/SourceLocation.h Wed Dec 12 16:39:36 2007 @@ -17,9 +17,14 @@ #include #include "llvm/Bitcode/SerializationFwd.h" +namespace llvm { +class MemoryBuffer; +} + namespace clang { class SourceManager; +class FileEntry; /// SourceLocation - This is a carefully crafted 32-bit identifier that encodes /// a full include stack, line and column number information for a position in @@ -206,25 +211,50 @@ /// that expect both objects. class FullSourceLoc { SourceLocation Loc; - const SourceManager* SrcMgr; + SourceManager* SrcMgr; public: // Creates a FullSourceLoc where isValid() returns false. explicit FullSourceLoc() : Loc(SourceLocation()), SrcMgr((SourceManager*) 0) {} - explicit FullSourceLoc(SourceLocation loc, const SourceManager& smgr) - : Loc(loc), SrcMgr(&smgr) { - assert (loc.isValid() && "SourceLocation must be valid!"); - } + explicit FullSourceLoc(SourceLocation loc, SourceManager& smgr) + : Loc(loc), SrcMgr(&smgr) {} bool isValid() const { return Loc.isValid(); } + bool isInvalid() const { return Loc.isInvalid(); } + + SourceLocation getLocation() const { return Loc; } - SourceLocation getSourceLocation() const { return Loc; } + SourceManager& getManager() { + assert (SrcMgr && "SourceManager is NULL."); + return *SrcMgr; + } const SourceManager& getManager() const { assert (SrcMgr && "SourceManager is NULL."); return *SrcMgr; } + + FullSourceLoc getLogicalLoc(); + FullSourceLoc getIncludeLoc(); + + unsigned getLineNumber(); + unsigned getColumnNumber(); + + const char *getCharacterData() const; + + const llvm::MemoryBuffer* getBuffer() const; + + const char* getSourceName() const; + const FileEntry* getFileEntryForLoc() const; + + bool operator==(const FullSourceLoc& RHS) const { + return SrcMgr == RHS.SrcMgr && Loc == RHS.Loc; + } + + bool operator!=(const FullSourceLoc& RHS) const { + return SrcMgr != RHS.SrcMgr || Loc != RHS.Loc; + } }; } // end namespace clang Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Dec 12 16:39:36 2007 @@ -42,9 +42,6 @@ /// diagnostic info, but does expect them to be alive for as long as it is. /// class TargetInfo { - /// SrcMgr - The SourceManager associated with this TargetInfo. - SourceManager& SrcMgr; - /// Primary - This tracks the primary target in the target set. /// const TargetInfoImpl *PrimaryTarget; @@ -69,8 +66,7 @@ // TargetInfo Construction. //==----------------------------------------------------------------==/ - TargetInfo(SourceManager& SMgr, const TargetInfoImpl *Primary, - Diagnostic *D = 0) : SrcMgr(SMgr) { + TargetInfo(const TargetInfoImpl *Primary, Diagnostic *D = 0) { PrimaryTarget = Primary; Diag = D; NonPortable = false; @@ -83,8 +79,7 @@ /// CreateTargetInfo - Create a TargetInfo object from a group of /// target triples. The first target triple is considered the primary /// target. - static TargetInfo* CreateTargetInfo(SourceManager& SrcMgr, - const std::string* TriplesBeg, + static TargetInfo* CreateTargetInfo(const std::string* TriplesBeg, const std::string* TripledEnd, Diagnostic* Diags = NULL); @@ -114,7 +109,7 @@ /// DiagnoseNonPortability - Emit a diagnostic indicating that the current /// translation unit is non-portable due to a construct at the specified /// location. DiagKind indicates what went wrong. - void DiagnoseNonPortability(SourceLocation Loc, unsigned DiagKind); + void DiagnoseNonPortability(FullSourceLoc Loc, unsigned DiagKind); /// getTargetDefines - Appends the target-specific #define values for this /// target set to the specified buffer. @@ -123,70 +118,71 @@ /// isCharSigned - Return true if 'char' is 'signed char' or false if it is /// treated as 'unsigned char'. This is implementation defined according to /// C99 6.2.5p15. In our implementation, this is target-specific. - bool isCharSigned(SourceLocation Loc) { + bool isCharSigned(FullSourceLoc Loc) { // FIXME: implement correctly. return true; } /// getPointerWidth - Return the width of pointers on this target, we /// currently assume one pointer type. - void getPointerInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) { + void getPointerInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) { Size = 32; // FIXME: implement correctly. Align = 32; } /// getBoolInfo - Return the size of '_Bool' and C++ 'bool' for this target, /// in bits. - void getBoolInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) { + void getBoolInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) { Size = Align = 8; // FIXME: implement correctly: wrong for ppc32. } /// getCharInfo - Return the size of 'char', 'signed char' and /// 'unsigned char' for this target, in bits. - void getCharInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) { + void getCharInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) { Size = Align = 8; // FIXME: implement correctly. } /// getShortInfo - Return the size of 'signed short' and 'unsigned short' for /// this target, in bits. - void getShortInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) { + void getShortInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) { Size = Align = 16; // FIXME: implement correctly. } /// getIntInfo - Return the size of 'signed int' and 'unsigned int' for this /// target, in bits. - void getIntInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) { + void getIntInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) { Size = Align = 32; // FIXME: implement correctly. } /// getLongInfo - Return the size of 'signed long' and 'unsigned long' for /// this target, in bits. - void getLongInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) { + void getLongInfo(uint64_t &Size, unsigned &Align, FullSourceLoc Loc) { Size = Align = 32; // FIXME: implement correctly: wrong for ppc64/x86-64 } /// getLongLongInfo - Return the size of 'signed long long' and /// 'unsigned long long' for this target, in bits. void getLongLongInfo(uint64_t &Size, unsigned &Align, - SourceLocation Loc) { + FullSourceLoc Loc) { Size = Align = 64; // FIXME: implement correctly. } /// getFloatInfo - Characterize 'float' for this target. void getFloatInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format, SourceLocation Loc); + const llvm::fltSemantics *&Format, FullSourceLoc Loc); /// getDoubleInfo - Characterize 'double' for this target. void getDoubleInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format, SourceLocation Loc); + const llvm::fltSemantics *&Format, FullSourceLoc Loc); /// getLongDoubleInfo - Characterize 'long double' for this target. void getLongDoubleInfo(uint64_t &Size, unsigned &Align, - const llvm::fltSemantics *&Format, SourceLocation Loc); + const llvm::fltSemantics *&Format, FullSourceLoc Loc); /// getWCharInfo - Return the size of wchar_t in bits. /// - void getWCharInfo(uint64_t &Size, unsigned &Align, SourceLocation Loc) { + void getWCharInfo(uint64_t &Size, unsigned &Align, + FullSourceLoc Loc) { if (!WCharWidth) ComputeWCharInfo(Loc); Size = WCharWidth; Align = WCharAlign; @@ -194,7 +190,7 @@ /// getIntMaxTWidth - Return the size of intmax_t and uintmax_t for this /// target, in bits. - unsigned getIntMaxTWidth(SourceLocation Loc) { + unsigned getIntMaxTWidth(FullSourceLoc Loc) { // FIXME: implement correctly. return 64; } @@ -237,31 +233,31 @@ ///===---- Some helper methods ------------------------------------------===// - unsigned getCharWidth(SourceLocation Loc) { + unsigned getCharWidth(FullSourceLoc Loc) { uint64_t Size; unsigned Align; getCharInfo(Size, Align, Loc); return static_cast(Size); } - unsigned getWCharWidth(SourceLocation Loc) { + unsigned getWCharWidth(FullSourceLoc Loc) { uint64_t Size; unsigned Align; getWCharInfo(Size, Align, Loc); return static_cast(Size); } - unsigned getIntWidth(SourceLocation Loc) { + unsigned getIntWidth(FullSourceLoc Loc) { uint64_t Size; unsigned Align; getIntInfo(Size, Align, Loc); return static_cast(Size); } - unsigned getLongWidth(SourceLocation Loc) { + unsigned getLongWidth(FullSourceLoc Loc) { uint64_t Size; unsigned Align; getLongInfo(Size, Align, Loc); return static_cast(Size); } - unsigned getLongLongWidth(SourceLocation Loc) { + unsigned getLongLongWidth(FullSourceLoc Loc) { uint64_t Size; unsigned Align; getLongLongInfo(Size, Align, Loc); return static_cast(Size); @@ -281,7 +277,7 @@ 32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"; } private: - void ComputeWCharInfo(SourceLocation Loc); + void ComputeWCharInfo(FullSourceLoc Loc); }; Modified: cfe/trunk/include/clang/Parse/DeclSpec.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=44957&r1=44956&r2=44957&view=diff ============================================================================== --- cfe/trunk/include/clang/Parse/DeclSpec.h (original) +++ cfe/trunk/include/clang/Parse/DeclSpec.h Wed Dec 12 16:39:36 2007 @@ -271,12 +271,12 @@ private: void Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr, unsigned DiagID) { - D.Report(Loc, DiagID, SrcMgr); + D.Report(FullSourceLoc(Loc,SrcMgr), DiagID); } void Diag(Diagnostic &D, SourceLocation Loc, SourceManager& SrcMgr, unsigned DiagID, const std::string &info) { - D.Report(Loc, DiagID, SrcMgr, &info, 1); + D.Report(FullSourceLoc(Loc,SrcMgr), DiagID, &info, 1); } }; From kremenek at apple.com Wed Dec 12 17:41:09 2007 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 12 Dec 2007 23:41:09 -0000 Subject: [cfe-commits] r44962 - in /cfe/trunk/Driver: TranslationUnit.h clang.cpp Message-ID: <200712122341.lBCNfABl020112@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 17:41:08 2007 New Revision: 44962 URL: http://llvm.org/viewvc/llvm-project?rev=44962&view=rev Log: Implemented prototype mode where the driver can operate on serialized ASTs instead of source files. Modified: cfe/trunk/Driver/TranslationUnit.h cfe/trunk/Driver/clang.cpp Modified: cfe/trunk/Driver/TranslationUnit.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TranslationUnit.h?rev=44962&r1=44961&r2=44962&view=diff ============================================================================== --- cfe/trunk/Driver/TranslationUnit.h (original) +++ cfe/trunk/Driver/TranslationUnit.h Wed Dec 12 17:41:08 2007 @@ -43,6 +43,8 @@ : LangOpts(lopt), Context(&context) {} void setContext(ASTContext* context) { Context = context; } + ASTContext* getContext() const { return Context; } + const LangOptions& getLangOpts() const { return LangOpts; } /// EmitBitcodeFile - Emit the translation unit to a bitcode file. bool EmitBitcodeFile(llvm::sys::Path& Filename) const; Modified: cfe/trunk/Driver/clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=44962&r1=44961&r2=44962&view=diff ============================================================================== --- cfe/trunk/Driver/clang.cpp (original) +++ cfe/trunk/Driver/clang.cpp Wed Dec 12 17:41:08 2007 @@ -26,6 +26,7 @@ #include "ASTConsumers.h" #include "TextDiagnosticBuffer.h" #include "TextDiagnosticPrinter.h" +#include "TranslationUnit.h" #include "clang/Sema/ASTStreamer.h" #include "clang/AST/ASTConsumer.h" #include "clang/Parse/Parser.h" @@ -947,9 +948,54 @@ } } +static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag, + FileManager& FileMgr) { + + if (VerifyDiagnostics) { + fprintf(stderr, "-verify does not yet work with serialized ASTs.\n"); + exit (1); + } + + llvm::sys::Path Filename(InFile); + + if (!Filename.isValid()) { + fprintf(stderr, "serialized file '%s' not available.\n",InFile.c_str()); + exit (1); + } + + TranslationUnit* TU = TranslationUnit::ReadBitcodeFile(Filename,FileMgr); + ASTConsumer* Consumer = CreateASTConsumer(Diag,FileMgr,TU->getLangOpts()); + + if (!Consumer) { + fprintf(stderr, "Unsupported program action with serialized ASTs!\n"); + exit (1); + } + + // FIXME: only work on consumers that do not require MainFileID. + Consumer->Initialize(*TU->getContext(),0); + + for (TranslationUnit::iterator I=TU->begin(), E=TU->end(); I!=E; ++I) + Consumer->HandleTopLevelDecl(*I); + + delete Consumer; +} + + static llvm::cl::list InputFilenames(llvm::cl::Positional, llvm::cl::desc("")); +static bool isSerializedFile(const std::string& InFile) { + if (InFile.size() < 4) + return false; + + const char* s = InFile.c_str()+InFile.size()-4; + + return s[0] == '.' && + s[1] == 'a' && + s[2] == 's' && + s[3] == 't'; +} + int main(int argc, char **argv) { llvm::cl::ParseCommandLineOptions(argc, argv, " llvm cfe\n"); @@ -994,59 +1040,63 @@ for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) { const std::string &InFile = InputFilenames[i]; - - /// Create a SourceManager object. This tracks and owns all the file - /// buffers allocated to a translation unit. - SourceManager SourceMgr; - - // Initialize language options, inferring file types from input filenames. - LangOptions LangInfo; - InitializeBaseLanguage(); - LangKind LK = GetLanguage(InFile); - InitializeLangOptions(LangInfo, LK); - InitializeLanguageStandard(LangInfo, LK); - - // Process the -I options and set them in the HeaderInfo. - HeaderSearch HeaderInfo(FileMgr); - DiagClient->setHeaderSearch(HeaderInfo); - InitializeIncludePaths(HeaderInfo, FileMgr, LangInfo); - // Get information about the targets being compiled for. Note that this - // pointer and the TargetInfoImpl objects are never deleted by this toy - // driver. - TargetInfo *Target; - - // Create triples, and create the TargetInfo. - std::vector triples; - CreateTargetTriples(triples); - Target = TargetInfo::CreateTargetInfo(&triples[0], - &triples[0]+triples.size(), - &Diags); - - if (Target == 0) { - fprintf(stderr, "Sorry, I don't know what target this is: %s\n", - triples[0].c_str()); - fprintf(stderr, "Please use -triple or -arch.\n"); - exit(1); - } - - // Set up the preprocessor with these options. - Preprocessor PP(Diags, LangInfo, *Target, SourceMgr, HeaderInfo); - - std::vector PredefineBuffer; - unsigned MainFileID = InitializePreprocessor(PP, InFile, SourceMgr, - HeaderInfo, LangInfo, - PredefineBuffer); - - if (!MainFileID) continue; + if (isSerializedFile(InFile)) + ProcessSerializedFile(InFile,Diags,FileMgr); + else { + /// Create a SourceManager object. This tracks and owns all the file + /// buffers allocated to a translation unit. + SourceManager SourceMgr; + + // Initialize language options, inferring file types from input filenames. + LangOptions LangInfo; + InitializeBaseLanguage(); + LangKind LK = GetLanguage(InFile); + InitializeLangOptions(LangInfo, LK); + InitializeLanguageStandard(LangInfo, LK); + + // Process the -I options and set them in the HeaderInfo. + HeaderSearch HeaderInfo(FileMgr); + DiagClient->setHeaderSearch(HeaderInfo); + InitializeIncludePaths(HeaderInfo, FileMgr, LangInfo); + + // Get information about the targets being compiled for. Note that this + // pointer and the TargetInfoImpl objects are never deleted by this toy + // driver. + TargetInfo *Target; + + // Create triples, and create the TargetInfo. + std::vector triples; + CreateTargetTriples(triples); + Target = TargetInfo::CreateTargetInfo(&triples[0], + &triples[0]+triples.size(), + &Diags); + + if (Target == 0) { + fprintf(stderr, "Sorry, I don't know what target this is: %s\n", + triples[0].c_str()); + fprintf(stderr, "Please use -triple or -arch.\n"); + exit(1); + } + + // Set up the preprocessor with these options. + Preprocessor PP(Diags, LangInfo, *Target, SourceMgr, HeaderInfo); + + std::vector PredefineBuffer; + unsigned MainFileID = InitializePreprocessor(PP, InFile, SourceMgr, + HeaderInfo, LangInfo, + PredefineBuffer); + + if (!MainFileID) continue; - ProcessInputFile(PP, MainFileID, InFile, SourceMgr, - *DiagClient, HeaderInfo, LangInfo); - - HeaderInfo.ClearFileInfo(); - - if (Stats) - SourceMgr.PrintStats(); + ProcessInputFile(PP, MainFileID, InFile, SourceMgr, + *DiagClient, HeaderInfo, LangInfo); + + HeaderInfo.ClearFileInfo(); + + if (Stats) + SourceMgr.PrintStats(); + } } unsigned NumDiagnostics = Diags.getNumDiagnostics(); From sabre at nondot.org Wed Dec 12 17:46:37 2007 From: sabre at nondot.org (Chris Lattner) Date: Wed, 12 Dec 2007 23:46:37 -0000 Subject: [cfe-commits] r44963 - /cfe/trunk/CodeGen/CodeGenModule.cpp Message-ID: <200712122346.lBCNkbcE020376@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 17:46:36 2007 New Revision: 44963 URL: http://llvm.org/viewvc/llvm-project?rev=44963&view=rev Log: fix off-by-one error. Modified: cfe/trunk/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=44963&r1=44962&r2=44963&view=diff ============================================================================== --- cfe/trunk/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/CodeGen/CodeGenModule.cpp Wed Dec 12 17:46:36 2007 @@ -519,7 +519,7 @@ /// getBuiltinLibFunction llvm::Function *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) { if (BuiltinFunctions.size() <= BuiltinID) - BuiltinFunctions.resize(BuiltinID); + BuiltinFunctions.resize(BuiltinID+1); // Already available? llvm::Function *&FunctionSlot = BuiltinFunctions[BuiltinID]; From fjahanian at apple.com Wed Dec 12 17:55:49 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Wed, 12 Dec 2007 23:55:49 -0000 Subject: [cfe-commits] r44964 - in /cfe/trunk: Parse/ParseObjc.cpp Sema/SemaExpr.cpp test/Sema/objc-string-concat-1.m Message-ID: <200712122355.lBCNtnWY020860@zion.cs.uiuc.edu> Author: fjahanian Date: Wed Dec 12 17:55:49 2007 New Revision: 44964 URL: http://llvm.org/viewvc/llvm-project?rev=44964&view=rev Log: Concatenation of objc strings. Added: cfe/trunk/test/Sema/objc-string-concat-1.m Modified: cfe/trunk/Parse/ParseObjc.cpp cfe/trunk/Sema/SemaExpr.cpp Modified: cfe/trunk/Parse/ParseObjc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=44964&r1=44963&r2=44964&view=diff ============================================================================== --- cfe/trunk/Parse/ParseObjc.cpp (original) +++ cfe/trunk/Parse/ParseObjc.cpp Wed Dec 12 17:55:49 2007 @@ -1397,7 +1397,7 @@ AtStrings.push_back(Res.Val); } - + return Actions.ParseObjCStringLiteral(&AtLocs[0], &AtStrings[0], AtStrings.size()); } Modified: cfe/trunk/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=44964&r1=44963&r2=44964&view=diff ============================================================================== --- cfe/trunk/Sema/SemaExpr.cpp (original) +++ cfe/trunk/Sema/SemaExpr.cpp Wed Dec 12 17:55:49 2007 @@ -2049,11 +2049,30 @@ Sema::ExprResult Sema::ParseObjCStringLiteral(SourceLocation *AtLocs, ExprTy **Strings, unsigned NumStrings) { - - // FIXME: This is passed in an ARRAY of strings which need to be concatenated. - // Handle this case here. For now we just ignore all but the first one. SourceLocation AtLoc = AtLocs[0]; StringLiteral* S = static_cast(Strings[0]); + if (NumStrings > 1) { + // Concatenate objc strings. + StringLiteral* ES = static_cast(Strings[NumStrings-1]); + SourceLocation EndLoc = ES->getSourceRange().getEnd(); + unsigned Length = 0; + for (unsigned i = 0; i < NumStrings; i++) + Length += static_cast(Strings[i])->getByteLength(); + char *strBuf = new char [Length]; + char *p = strBuf; + bool isWide = false; + for (unsigned i = 0; i < NumStrings; i++) { + S = static_cast(Strings[i]); + if (S->isWide()) + isWide = true; + memcpy(p, S->getStrData(), S->getByteLength()); + p += S->getByteLength(); + delete S; + } + S = new StringLiteral(strBuf, Length, + isWide, Context.getPointerType(Context.CharTy), + AtLoc, EndLoc); + } if (CheckBuiltinCFStringArgument(S)) return true; Added: cfe/trunk/test/Sema/objc-string-concat-1.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-string-concat-1.m?rev=44964&view=auto ============================================================================== --- cfe/trunk/test/Sema/objc-string-concat-1.m (added) +++ cfe/trunk/test/Sema/objc-string-concat-1.m Wed Dec 12 17:55:49 2007 @@ -0,0 +1,14 @@ +// RUN: clang -rewrite-test %s + + at class NSString; + + at interface NSConstantString; + at end + + + +NSConstantString *t0 = @"123"; +NSConstantString *t = @"123" @"4567"; // concat +NSConstantString *t1 = @"123" @"4567" /* COMMENT */ @"89"; // concat +NSConstantString *t2 = @"123" @/* COMMENT */ "4567"; // concat + From fjahanian at apple.com Wed Dec 12 18:16:34 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Thu, 13 Dec 2007 00:16:34 -0000 Subject: [cfe-commits] r44966 - /cfe/trunk/test/Sema/conflicting-ivar-test-1.m Message-ID: <200712130016.lBD0GYZU021772@zion.cs.uiuc.edu> Author: fjahanian Date: Wed Dec 12 18:16:34 2007 New Revision: 44966 URL: http://llvm.org/viewvc/llvm-project?rev=44966&view=rev Log: Fixed test to match the new diagnostic text. Modified: cfe/trunk/test/Sema/conflicting-ivar-test-1.m Modified: cfe/trunk/test/Sema/conflicting-ivar-test-1.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/conflicting-ivar-test-1.m?rev=44966&r1=44965&r2=44966&view=diff ============================================================================== --- cfe/trunk/test/Sema/conflicting-ivar-test-1.m (original) +++ cfe/trunk/test/Sema/conflicting-ivar-test-1.m Wed Dec 12 18:16:34 2007 @@ -21,7 +21,7 @@ { @public int IVAR; - int IVAR1; // expected-error {{inconsistent instance variable specification}} + int IVAR1; // expected-error {{inconsistent number of instance variables specified}} } @end @@ -46,7 +46,7 @@ @private int IVAR; - int IVAR1; // expected-error {{inconsistent instance variable specification}} + int IVAR1; // expected-error {{inconsistent number of instance variables specified}} } @end From kremenek at apple.com Wed Dec 12 18:37:32 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 00:37:32 -0000 Subject: [cfe-commits] r44967 - in /cfe/trunk/Driver: ASTConsumers.cpp ASTConsumers.h TranslationUnit.cpp TranslationUnit.h clang.cpp Message-ID: <200712130037.lBD0bW6M023774@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 18:37:31 2007 New Revision: 44967 URL: http://llvm.org/viewvc/llvm-project?rev=44967&view=rev Log: Implemented -serialize-ast option for the driver. This is not really tested and is a work in progress. Modified: cfe/trunk/Driver/ASTConsumers.cpp cfe/trunk/Driver/ASTConsumers.h cfe/trunk/Driver/TranslationUnit.cpp cfe/trunk/Driver/TranslationUnit.h cfe/trunk/Driver/clang.cpp Modified: cfe/trunk/Driver/ASTConsumers.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=44967&r1=44966&r2=44967&view=diff ============================================================================== --- cfe/trunk/Driver/ASTConsumers.cpp (original) +++ cfe/trunk/Driver/ASTConsumers.cpp Wed Dec 12 18:37:31 2007 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "ASTConsumers.h" +#include "TranslationUnit.h" #include "clang/AST/AST.h" #include "clang/AST/ASTConsumer.h" #include "clang/AST/CFG.h" @@ -604,3 +605,40 @@ return new LLVMEmitter(Diags, Features); } +//===----------------------------------------------------------------------===// +// AST Serializer + +namespace { + class ASTSerializer : public ASTConsumer { + Diagnostic &Diags; + TranslationUnit TU; + const llvm::sys::Path FName; + public: + ASTSerializer(const llvm::sys::Path& F, Diagnostic &diags, + const LangOptions &LO) + : Diags(diags), TU(LO), FName(F) {} + + + virtual void Initialize(ASTContext &Context, unsigned MainFileID) { + TU.setContext(&Context); + } + + virtual void HandleTopLevelDecl(Decl *D) { + // If an error occurred, stop code generation, but continue parsing and + // semantic analysis (to ensure all warnings and errors are emitted). + if (Diags.hasErrorOccurred()) + return; + + TU.AddTopLevelDecl(D); + } + + ~ASTSerializer() { TU.EmitBitcodeFile(FName); } + }; +} // end anonymous namespace + + +ASTConsumer *clang::CreateASTSerializer(const llvm::sys::Path& FName, + Diagnostic &Diags, + const LangOptions &Features) { + return new ASTSerializer(FName, Diags, Features); +} Modified: cfe/trunk/Driver/ASTConsumers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.h?rev=44967&r1=44966&r2=44967&view=diff ============================================================================== --- cfe/trunk/Driver/ASTConsumers.h (original) +++ cfe/trunk/Driver/ASTConsumers.h Wed Dec 12 18:37:31 2007 @@ -16,6 +16,8 @@ #include +namespace llvm { namespace sys { class Path; }} + namespace clang { class ASTConsumer; @@ -34,6 +36,9 @@ ASTConsumer *CreateCodeRewriterTest(Diagnostic &Diags); ASTConsumer *CreateSerializationTest(Diagnostic &Diags, FileManager& FMgr, const LangOptions &LOpts); + +ASTConsumer *CreateASTSerializer(const llvm::sys::Path& FName, + Diagnostic &Diags, const LangOptions &LOpts); } // end clang namespace Modified: cfe/trunk/Driver/TranslationUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TranslationUnit.cpp?rev=44967&r1=44966&r2=44967&view=diff ============================================================================== --- cfe/trunk/Driver/TranslationUnit.cpp (original) +++ cfe/trunk/Driver/TranslationUnit.cpp Wed Dec 12 18:37:31 2007 @@ -33,7 +33,7 @@ using namespace clang; -bool TranslationUnit::EmitBitcodeFile(llvm::sys::Path& Filename) const { +bool TranslationUnit::EmitBitcodeFile(const llvm::sys::Path& Filename) const { // Reserve 256K for bitstream buffer. std::vector Buffer; @@ -122,8 +122,9 @@ Sezr.ExitBlock(); // exit "ASTContextBlock" } -TranslationUnit* TranslationUnit::ReadBitcodeFile(llvm::sys::Path& Filename, - FileManager& FMgr) { +TranslationUnit* +TranslationUnit::ReadBitcodeFile(const llvm::sys::Path& Filename, + FileManager& FMgr) { // Create the memory buffer that contains the contents of the file. llvm::scoped_ptr Modified: cfe/trunk/Driver/TranslationUnit.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TranslationUnit.h?rev=44967&r1=44966&r2=44967&view=diff ============================================================================== --- cfe/trunk/Driver/TranslationUnit.h (original) +++ cfe/trunk/Driver/TranslationUnit.h Wed Dec 12 18:37:31 2007 @@ -47,7 +47,7 @@ const LangOptions& getLangOpts() const { return LangOpts; } /// EmitBitcodeFile - Emit the translation unit to a bitcode file. - bool EmitBitcodeFile(llvm::sys::Path& Filename) const; + bool EmitBitcodeFile(const llvm::sys::Path& Filename) const; /// Emit - Emit the translation unit to an arbitray bitcode stream. void Emit(llvm::Serializer& S) const; @@ -56,7 +56,7 @@ static TranslationUnit* Create(llvm::Deserializer& D, FileManager& FMgr); /// ReadBitcodeFile - Reconsitute a translation unit from a bitcode file. - static TranslationUnit* ReadBitcodeFile(llvm::sys::Path& Filename, + static TranslationUnit* ReadBitcodeFile(const llvm::sys::Path& Filename, FileManager& FMgr); // Accessors Modified: cfe/trunk/Driver/clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=44967&r1=44966&r2=44967&view=diff ============================================================================== --- cfe/trunk/Driver/clang.cpp (original) +++ cfe/trunk/Driver/clang.cpp Wed Dec 12 18:37:31 2007 @@ -53,6 +53,7 @@ enum ProgActions { RewriteTest, // Rewriter testing stuff. EmitLLVM, // Emit a .ll file. + SerializeAST, // Emit a .ast file. ASTPrint, // Parse ASTs and print them. ASTDump, // Parse ASTs and dump them. ASTView, // Parse ASTs and view them in Graphviz. @@ -107,6 +108,8 @@ "Run prototype serializtion code."), clEnumValN(EmitLLVM, "emit-llvm", "Build ASTs then convert to LLVM, emit .ll file"), + clEnumValN(SerializeAST, "serialize-ast", + "Build ASTs and emit .ast file"), clEnumValN(RewriteTest, "rewrite-test", "Playground for the code rewriter"), clEnumValEnd)); @@ -816,7 +819,8 @@ /// CreateASTConsumer - Create the ASTConsumer for the corresponding program /// action. These consumers can operate on both ASTs that are freshly /// parsed from source files as well as those deserialized from Bitcode. -static ASTConsumer* CreateASTConsumer(Diagnostic& Diag, FileManager& FileMgr, +static ASTConsumer* CreateASTConsumer(const std::string& InFile, + Diagnostic& Diag, FileManager& FileMgr, const LangOptions& LangOpts) { switch (ProgAction) { default: @@ -850,6 +854,21 @@ case EmitLLVM: return CreateLLVMEmitter(Diag, LangOpts); + case SerializeAST: { + // FIXME: Allow user to tailor where the file is written. + llvm::sys::Path FName = llvm::sys::Path::GetTemporaryDirectory(NULL); + FName.appendComponent((InFile + ".ast").c_str()); + + if (FName.makeUnique(true,NULL)) { + fprintf (stderr, "error: cannot create serialized file: '%s'\n", + FName.c_str()); + + return NULL; + } + + return CreateASTSerializer(FName, Diag, LangOpts); + } + case RewriteTest: return CreateCodeRewriterTest(Diag); } @@ -869,7 +888,8 @@ switch (ProgAction) { default: - Consumer = CreateASTConsumer(PP.getDiagnostics(), HeaderInfo.getFileMgr(), + Consumer = CreateASTConsumer(InFile, PP.getDiagnostics(), + HeaderInfo.getFileMgr(), PP.getLangOptions()); if (!Consumer) { @@ -964,7 +984,8 @@ } TranslationUnit* TU = TranslationUnit::ReadBitcodeFile(Filename,FileMgr); - ASTConsumer* Consumer = CreateASTConsumer(Diag,FileMgr,TU->getLangOpts()); + ASTConsumer* Consumer = CreateASTConsumer(InFile,Diag, + FileMgr,TU->getLangOpts()); if (!Consumer) { fprintf(stderr, "Unsupported program action with serialized ASTs!\n"); From sabre at nondot.org Wed Dec 12 18:38:04 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 00:38:04 -0000 Subject: [cfe-commits] r44968 - /cfe/trunk/CodeGen/CodeGenModule.cpp Message-ID: <200712130038.lBD0c45x023844@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 18:38:03 2007 New Revision: 44968 URL: http://llvm.org/viewvc/llvm-project?rev=44968&view=rev Log: builtin id 0 is invalid, don't use a slot for it. Modified: cfe/trunk/CodeGen/CodeGenModule.cpp Modified: cfe/trunk/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenModule.cpp?rev=44968&r1=44967&r2=44968&view=diff ============================================================================== --- cfe/trunk/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/CodeGen/CodeGenModule.cpp Wed Dec 12 18:38:03 2007 @@ -518,11 +518,13 @@ /// getBuiltinLibFunction llvm::Function *CodeGenModule::getBuiltinLibFunction(unsigned BuiltinID) { - if (BuiltinFunctions.size() <= BuiltinID) - BuiltinFunctions.resize(BuiltinID+1); + if (BuiltinID > BuiltinFunctions.size()) + BuiltinFunctions.resize(BuiltinID); - // Already available? - llvm::Function *&FunctionSlot = BuiltinFunctions[BuiltinID]; + // Cache looked up functions. Since builtin id #0 is invalid we don't reserve + // a slot for it. + assert(BuiltinID && "Invalid Builtin ID"); + llvm::Function *&FunctionSlot = BuiltinFunctions[BuiltinID-1]; if (FunctionSlot) return FunctionSlot; From fjahanian at apple.com Wed Dec 12 18:54:18 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Thu, 13 Dec 2007 00:54:18 -0000 Subject: [cfe-commits] r44972 - in /cfe/trunk: AST/DeclSerialization.cpp include/clang/AST/Decl.h Message-ID: <200712130054.lBD0sImM024883@zion.cs.uiuc.edu> Author: fjahanian Date: Wed Dec 12 18:54:18 2007 New Revision: 44972 URL: http://llvm.org/viewvc/llvm-project?rev=44972&view=rev Log: Moved ObjcDeclQualifier to ParmVarDecl from VarDecl. Ted, this change necessitates (de)/serialization of ParmVarDecl. Modified: cfe/trunk/AST/DeclSerialization.cpp cfe/trunk/include/clang/AST/Decl.h Modified: cfe/trunk/AST/DeclSerialization.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/DeclSerialization.cpp?rev=44972&r1=44971&r2=44972&view=diff ============================================================================== --- cfe/trunk/AST/DeclSerialization.cpp (original) +++ cfe/trunk/AST/DeclSerialization.cpp Wed Dec 12 18:54:18 2007 @@ -146,13 +146,15 @@ void VarDecl::EmitInRec(Serializer& S) const { ValueDecl::EmitInRec(S); S.EmitInt(getStorageClass()); // From VarDecl. - S.EmitInt(getObjcDeclQualifier()); // From VarDecl. + // FIXME: This is now in ParmVarDecl + // S.EmitInt(getObjcDeclQualifier()); // From VarDecl. } void VarDecl::ReadInRec(Deserializer& D) { ValueDecl::ReadInRec(D); - SClass = static_cast(D.ReadInt()); // From VarDecl. - objcDeclQualifier = static_cast(D.ReadInt()); // VarDecl. + SClass = static_cast(D.ReadInt()); // From VarDecl. + // FIXME: This is now in ParmVarDecl + // objcDeclQualifier = static_cast(D.ReadInt()); // VarDecl. } //===------------------------------------------------------------===// Modified: cfe/trunk/include/clang/AST/Decl.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=44972&r1=44971&r2=44972&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Decl.h (original) +++ cfe/trunk/include/clang/AST/Decl.h Wed Dec 12 18:54:18 2007 @@ -319,10 +319,6 @@ // as static variables declared within a function. bool hasGlobalStorage() const { return !hasAutoStorage(); } - ObjcDeclQualifier getObjcDeclQualifier() const { return objcDeclQualifier; } - void setObjcDeclQualifier(ObjcDeclQualifier QTVal) - { objcDeclQualifier = QTVal; } - // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() >= VarFirst && D->getKind() <= VarLast; @@ -331,16 +327,12 @@ protected: VarDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass SC, ScopedDecl *PrevDecl, AttributeList *A = 0) - : ValueDecl(DK, L, Id, T, PrevDecl, A), Init(0), - objcDeclQualifier(OBJC_TQ_None) { SClass = SC; } + : ValueDecl(DK, L, Id, T, PrevDecl, A), Init(0) { SClass = SC; } private: Expr *Init; // FIXME: This can be packed into the bitfields in Decl. unsigned SClass : 3; - /// FIXME: Also can be paced into the bitfields in Decl. - /// in, inout, etc. - ObjcDeclQualifier objcDeclQualifier : 6; - + friend class StmtIteratorBase; protected: @@ -401,12 +393,22 @@ public: ParmVarDecl(SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S, ScopedDecl *PrevDecl, AttributeList *A = 0) - : VarDecl(ParmVar, L, Id, T, S, PrevDecl, A) {} + : VarDecl(ParmVar, L, Id, T, S, PrevDecl, A), + objcDeclQualifier(OBJC_TQ_None) {} + ObjcDeclQualifier getObjcDeclQualifier() const { return objcDeclQualifier; } + void setObjcDeclQualifier(ObjcDeclQualifier QTVal) + { objcDeclQualifier = QTVal; } + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return D->getKind() == ParmVar; } static bool classof(const ParmVarDecl *D) { return true; } +private: + /// FIXME: Also can be paced into the bitfields in Decl. + /// in, inout, etc. + ObjcDeclQualifier objcDeclQualifier : 6; + protected: /// CreateImpl - Deserialize a ParmVarDecl. Called by Decl::Create. static ParmVarDecl* CreateImpl(llvm::Deserializer& D); From clattner at apple.com Wed Dec 12 19:00:16 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 17:00:16 -0800 Subject: [cfe-commits] r43948 - in /cfe/trunk: Sema/SemaDecl.cpp Sema/SemaType.cpp test/Sema/method-encoding-2.m In-Reply-To: <0668869A-2D7E-44E2-9B9A-7F4572F571B7@apple.com> References: <200711091718.lA9HIVgW002914@zion.cs.uiuc.edu> <2190421E-1A23-4519-A9A0-9BC1205DA4B9@apple.com> <0668869A-2D7E-44E2-9B9A-7F4572F571B7@apple.com> Message-ID: <3ABA352F-1623-419F-9239-E0F29026FC49@apple.com> On Dec 12, 2007, at 9:36 AM, Fariborz Jahanian wrote: > > On Dec 11, 2007, at 11:15 PM, Chris Lattner wrote: > >> On Nov 9, 2007, at 9:18 AM, Fariborz Jahanian wrote: >>> Author: fjahanian >>> Date: Fri Nov 9 11:18:29 2007 >>> New Revision: 43948 >>> >>> Insert invisble arguments to method definition header. >> >> Hi Fariborz, >> >> The code for handling self etc evolved into: >> >> void Sema::ObjcActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { >> ... >> // Create Decl objects for each parameter, entrring them in the >> scope for >> // binding to their use. >> struct DeclaratorChunk::ParamInfo PI; >> >> // Insert the invisible arguments, self and _cmd! >> PI.Ident = &Context.Idents.get("self"); >> PI.IdentLoc = SourceLocation(); // synthesized vars have a null >> location. >> PI.InvalidType = false; >> if (MDecl->isInstance()) { >> QualType selfTy = Context.getObjcInterfaceType(MDecl- >> >getClassInterface()); >> selfTy = Context.getPointerType(selfTy); >> PI.TypeInfo = selfTy.getAsOpaquePtr(); >> } else >> PI.TypeInfo = Context.getObjcIdType().getAsOpaquePtr(); >> CurMethodDecl->setSelfDecl(ActOnParamDeclarator(PI, FnBodyScope)); >> >> similarly for _cmd. >> >> Questions: >> >> 1. Why are these turning into ParamVarDecls? These are not >> parameters in the source language, they are magic variables. > > I agree that this is an implementation detail. This was a quick way > to support binding to the use of 'self' as variable which refers to > receiver of message in methods. Post-demo, we talked about > providing a special Decl node for the use of 'self' (which requires > more substantive changes). Right. Similiarly in C++ we have 'this'. Maybe something like MagicVarDecl or something? One other change that would be nice is to create these things lazily on the first time they are used. That way, an ObjC method would only get a decl for self if explicitly referenced. This is even more important for _cmd as it is almost never used. >> 2. Why are you setting up a declarator chunk and passing stuff >> through ActOnParamDeclarator? This code is in Sema already, so it >> seems like this layer of indirection is not needed. > > I don't remember this code; presumably done to enter the parameter > into scope. Maybe Steve has an explanation. Ok, please investigate to see how hard it is to change when you have time, Thanks! -Chris From clattner at apple.com Wed Dec 12 19:00:30 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 17:00:30 -0800 Subject: [cfe-commits] r43534 - in /cfe/trunk: Sema/SemaDecl.cpp clang.xcodeproj/project.pbxproj include/clang/AST/Decl.h include/clang/AST/DeclObjC.h In-Reply-To: <5CCABBBD-0CBF-4C6A-A0F6-1DD4877C7FAE@apple.com> References: <200710310012.l9V0CZW6004188@zion.cs.uiuc.edu> <4720021F-6D3C-4039-B289-E4B4BFD916E8@apple.com> <5CCABBBD-0CBF-4C6A-A0F6-1DD4877C7FAE@apple.com> Message-ID: <3403050C-1181-4F05-A03F-B587AC01C302@apple.com> On Dec 12, 2007, at 9:21 AM, Fariborz Jahanian wrote: > > On Dec 11, 2007, at 10:05 PM, Chris Lattner wrote: > >> On Oct 30, 2007, at 5:12 PM, Fariborz Jahanian wrote: >>> Author: fjahanian >>> Date: Tue Oct 30 19:12:35 2007 >>> New Revision: 43534 >>> >>> Added new type and bitfield fields in some decl types in >>> preparation for objective-c's type qualifiers. >>> Added initialization of Class/SEMA types. >> >> Hi Fariborz, >> >> This patch adds ObjcDeclQualifier to VarDecl. Doesn't it make >> more sense for them to be on ParmVarDecl? > > Yes it does. I will make the change later today. Thanks Fariborz! -Chris From clattner at apple.com Wed Dec 12 19:03:44 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 17:03:44 -0800 Subject: [cfe-commits] r43989 - in /cfe/trunk: AST/Decl.cpp Sema/Sema.h Sema/SemaDecl.cpp Sema/SemaExpr.cpp include/clang/AST/DeclObjC.h test/Sema/message.m In-Reply-To: <7CB5AA87-F214-43E1-B4D3-F66B9618D7BC@apple.com> References: <200711110010.lAB0AmpG018214@zion.cs.uiuc.edu> <73CC5ED6-31CD-4446-B39E-A4629C7F5F58@apple.com> <7CB5AA87-F214-43E1-B4D3-F66B9618D7BC@apple.com> Message-ID: <31F8FE93-5E0B-447C-8A6F-10AEFBEE98AE@apple.com> >> 3. There are inconsistencies in the ObjC class interfaces. For >> example, it is ObjcInterfaceDecl::getNumInstanceVariables but it >> is ObjcImplementationDecl::getImplDeclNumIvars. This is >> strangeness. Please pick a set of shorthand (e.g. Inst for >> instance, Proto for protocol, Meth for method, Vars for variables >> etc) and use it consistently. Many method names are really long. >> getNumInstanceVariables should get getNumInstVars() or getNumIVars(). >> > > I agree with removing the inconsistency. There are two consistency > issues here: (1) the ObjC AST API's should be self consistent. (2) > the ObjC AST API's should be consistent with the C AST API's. Ok. > That said, I think shortening the names (and coming up with a bunch > of abbreviations) is questionable. For example, the type checker > uses "getCanonicalType" all over the place. Here is an excerpt... > > QualType lhs = lhsExpr->getType().getCanonicalType > ().getUnqualifiedType(); > QualType rhs = rhsExpr->getType().getCanonicalType > ().getUnqualifiedType(); > > From my perspective, the Type accessors have long names. We could > consider converting them to... > > QualType lhs = lhsExpr->getType().getCanonType().getUnqualType(); > QualType rhs = rhsExpr->getType().getCanonType().getUnqualType(); > > From my perspective, this would be the wrong decision (since the > original names are "good"). Ok. > I general, I don't believe shortening names just for the sake of > shortening is the right decision. The names can certainly be > improved. I just don't see a general/good solution to your > complaint that "Many method names are really long". I'm much more concerned with consistency than terseness, I'm happy to go with consistent but long names :) >> 4. There are 4 or 5 implementations of lookupInstanceMethod, and >> they all do different things. :( Please pick a name that is >> more specific to the various classes that explains how it >> searches. For example, >> ObjcImplementationDecl::lookupInstanceMethod could be >> ObjcImplementationDecl::findDefinedInstMethod(), which makes it >> more clear that it only returns things *defined in the >> @implementation*. >> > > I disagree with your assertion that "they all do different things. : > (". From my perspective, using polymorphism here makes sense. Some do a "shallow" lookup, others walk the inheritance chain. It should be clear from their name what they do. >> 5. Related, I think you should split >> ObjcProtocolDecl::lookupInstanceMethod up into two things: one >> that searches locally, and one that walks the "referenced >> protocols", calling the local search on each one. Likewise for >> any similar ones. >> > > I think having different ways to search is fine. Off hand, I don't > know if I prefer a "knob" (on an existing API) or a new API. To > some extent is depends on how we resolve the naming/polymorphism > issues above. Please split it into two functions, where one calls the other. instead of "lookupInstanceMethod" how about getinstanceMethodBySelector() or something? Wow that name is long ;-) >> 6. One specific question is that >> ObjcInterfaceDecl::lookupInstanceMethod scans methods immediately >> referenced in protocols, but it doesn't scan protocol's parent >> protocols. Is this correct? Either way, please change it to call >> the methods added in step #5. >> > I agree with you...I don't believe this is correct. > ObjcInterfaceDecl should likely query the protocol directly (rather > than iterate over the protocols instance methods directly). Ok. Thanks Steve, -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/cfe-commits/attachments/20071212/13feaa2e/attachment-0001.html From snaroff at apple.com Wed Dec 12 19:11:20 2007 From: snaroff at apple.com (Steve Naroff) Date: Wed, 12 Dec 2007 17:11:20 -0800 Subject: [cfe-commits] r43989 - in /cfe/trunk: AST/Decl.cpp Sema/Sema.h Sema/SemaDecl.cpp Sema/SemaExpr.cpp include/clang/AST/DeclObjC.h test/Sema/message.m In-Reply-To: <31F8FE93-5E0B-447C-8A6F-10AEFBEE98AE@apple.com> References: <200711110010.lAB0AmpG018214@zion.cs.uiuc.edu> <73CC5ED6-31CD-4446-B39E-A4629C7F5F58@apple.com> <7CB5AA87-F214-43E1-B4D3-F66B9618D7BC@apple.com> <31F8FE93-5E0B-447C-8A6F-10AEFBEE98AE@apple.com> Message-ID: <408491B0-9DD0-48E3-91E0-D2B1E4A7E71B@apple.com> On Dec 12, 2007, at 5:03 PM, Chris Lattner wrote: >>> 3. There are inconsistencies in the ObjC class interfaces. For >>> example, it is ObjcInterfaceDecl::getNumInstanceVariables but it >>> is ObjcImplementationDecl::getImplDeclNumIvars. This is >>> strangeness. Please pick a set of shorthand (e.g. Inst for >>> instance, Proto for protocol, Meth for method, Vars for variables >>> etc) and use it consistently. Many method names are really long. >>> getNumInstanceVariables should get getNumInstVars() or >>> getNumIVars(). >>> >> >> I agree with removing the inconsistency. There are two consistency >> issues here: (1) the ObjC AST API's should be self consistent. (2) >> the ObjC AST API's should be consistent with the C AST API's. > > Ok. > >> That said, I think shortening the names (and coming up with a bunch >> of abbreviations) is questionable. For example, the type checker >> uses "getCanonicalType" all over the place. Here is an excerpt... >> >> QualType lhs = lhsExpr- >> >getType().getCanonicalType().getUnqualifiedType(); >> QualType rhs = rhsExpr- >> >getType().getCanonicalType().getUnqualifiedType(); >> >> From my perspective, the Type accessors have long names. We could >> consider converting them to... >> >> QualType lhs = lhsExpr->getType().getCanonType().getUnqualType(); >> QualType rhs = rhsExpr->getType().getCanonType().getUnqualType(); >> >> From my perspective, this would be the wrong decision (since the >> original names are "good"). > > Ok. > >> I general, I don't believe shortening names just for the sake of >> shortening is the right decision. The names can certainly be >> improved. I just don't see a general/good solution to your >> complaint that "Many method names are really long". > > I'm much more concerned with consistency than terseness, I'm happy > to go with consistent but long names :) > Great. For the AST's, I'd like to stay away from terse, overly abbreviated names. For API's that are less public, I don't care as much... >>> 4. There are 4 or 5 implementations of lookupInstanceMethod, and >>> they all do different things. :( Please pick a name that is >>> more specific to the various classes that explains how it >>> searches. For example, >>> ObjcImplementationDecl::lookupInstanceMethod could be >>> ObjcImplementationDecl::findDefinedInstMethod(), which makes it >>> more clear that it only returns things *defined in the >>> @implementation*. >>> >> >> I disagree with your assertion that "they all do different things. : >> (". From my perspective, using polymorphism here makes sense. > > Some do a "shallow" lookup, others walk the inheritance chain. It > should be clear from their name what they do. > >>> 5. Related, I think you should split >>> ObjcProtocolDecl::lookupInstanceMethod up into two things: one >>> that searches locally, and one that walks the "referenced >>> protocols", calling the local search on each one. Likewise for >>> any similar ones. >>> >> >> I think having different ways to search is fine. Off hand, I don't >> know if I prefer a "knob" (on an existing API) or a new API. To >> some extent is depends on how we resolve the naming/polymorphism >> issues above. > > Please split it into two functions, where one calls the other. > instead of "lookupInstanceMethod" how about > getinstanceMethodBySelector() or something? Wow that name is long ;-) > I understand what you looking for...I'll consider this approach and make a proposal. snaroff >>> 6. One specific question is that >>> ObjcInterfaceDecl::lookupInstanceMethod scans methods immediately >>> referenced in protocols, but it doesn't scan protocol's parent >>> protocols. Is this correct? Either way, please change it to call >>> the methods added in step #5. >>> >> I agree with you...I don't believe this is correct. >> ObjcInterfaceDecl should likely query the protocol directly (rather >> than iterate over the protocols instance methods directly). > > Ok. > > Thanks Steve, > > -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/cfe-commits/attachments/20071212/82dbd589/attachment.html From clattner at apple.com Wed Dec 12 19:13:25 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 17:13:25 -0800 Subject: [cfe-commits] r43989 - in /cfe/trunk: AST/Decl.cpp Sema/Sema.h Sema/SemaDecl.cpp Sema/SemaExpr.cpp include/clang/AST/DeclObjC.h test/Sema/message.m In-Reply-To: <408491B0-9DD0-48E3-91E0-D2B1E4A7E71B@apple.com> References: <200711110010.lAB0AmpG018214@zion.cs.uiuc.edu> <73CC5ED6-31CD-4446-B39E-A4629C7F5F58@apple.com> <7CB5AA87-F214-43E1-B4D3-F66B9618D7BC@apple.com> <31F8FE93-5E0B-447C-8A6F-10AEFBEE98AE@apple.com> <408491B0-9DD0-48E3-91E0-D2B1E4A7E71B@apple.com> Message-ID: <4368DAA3-034C-4F0F-BF2E-4D4262C96013@apple.com> On Dec 12, 2007, at 5:11 PM, Steve Naroff wrote: > Please split it into two functions, where one calls the other. > instead of "lookupInstanceMethod" how about > getinstanceMethodBySelector() or something? Wow that name is long ;-) > > > I understand what you looking for...I'll consider this approach and > make a proposal. > Ok, thanks! -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/cfe-commits/attachments/20071212/79e5975f/attachment.html From dpatel at apple.com Wed Dec 12 19:24:16 2007 From: dpatel at apple.com (Devang Patel) Date: Thu, 13 Dec 2007 01:24:16 -0000 Subject: [cfe-commits] r44974 - /cfe/trunk/CodeGen/CodeGenTypes.cpp Message-ID: <200712130124.lBD1OGJo028379@zion.cs.uiuc.edu> Author: dpatel Date: Wed Dec 12 19:24:16 2007 New Revision: 44974 URL: http://llvm.org/viewvc/llvm-project?rev=44974&view=rev Log: Add assert to detect incomplete implementation work. Modified: cfe/trunk/CodeGen/CodeGenTypes.cpp Modified: cfe/trunk/CodeGen/CodeGenTypes.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenTypes.cpp?rev=44974&r1=44973&r2=44974&view=diff ============================================================================== --- cfe/trunk/CodeGen/CodeGenTypes.cpp (original) +++ cfe/trunk/CodeGen/CodeGenTypes.cpp Wed Dec 12 19:24:16 2007 @@ -594,6 +594,11 @@ } } } else if (ExtraBits >= BitFieldSize) { + const llvm::Type *Ty = CGT.ConvertType(FD->getType()); + uint64_t TySize = CGT.getTargetData().getABITypeSizeInBits(Ty); + assert ( Cursor - CurrentFieldStart + BitFieldSize <= TySize + && "Incomplete layout. struct {char a; int b:10; int c:18;};"); + // Reuse existing llvm field ExtraBits = ExtraBits - BitFieldSize; CGT.addFieldInfo(FD, FieldNo, Cursor - CurrentFieldStart, ExtraBits); @@ -604,13 +609,13 @@ const llvm::Type *Ty = CGT.ConvertType(FD->getType()); const llvm::Type *PrevTy = LLVMFields.back(); uint64_t TySize = CGT.getTargetData().getABITypeSizeInBits(Ty); - if (CGT.getTargetData().getABITypeSizeInBits(PrevTy) >= TySize) { - // Previous field does not allow sharing of ExtraBits. Use new field. - // struct { char a; char b:5; char c:4; } where c is current FD. - Cursor += ExtraBits; - ExtraBits = 0; - addLLVMField(Ty, TySize, FD, 0, BitFieldSize); - } else - assert (!FD->isBitField() && "Bit fields are not yet supported"); + assert (CGT.getTargetData().getABITypeSizeInBits(PrevTy) >= TySize + && "Unable to handle bit field"); + + // Previous field does not allow sharing of ExtraBits. Use new field. + // struct { char a; char b:5; char c:4; } where c is current FD. + Cursor += ExtraBits; + ExtraBits = 0; + addLLVMField(Ty, TySize, FD, 0, BitFieldSize); } } From clattner at apple.com Wed Dec 12 19:46:46 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 17:46:46 -0800 Subject: [cfe-commits] r44016 - in /cfe/trunk: AST/Expr.cpp AST/StmtPrinter.cpp AST/StmtSerialization.cpp Sema/SemaExpr.cpp include/clang/AST/Expr.h include/clang/AST/StmtNodes.def In-Reply-To: <200711121429.lACETerO002431@zion.cs.uiuc.edu> References: <200711121429.lACETerO002431@zion.cs.uiuc.edu> Message-ID: <260CCB27-8506-461E-84AE-6C5570C9FA2F@apple.com> On Nov 12, 2007, at 6:29 AM, Steve Naroff wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=44016&view=rev > Log: > Implement instance variable references. Hi Steve, /// ObjCIvarRefExpr - A reference to an ObjC instance variable. class ObjCIvarRefExpr : public Expr { class ObjcIvarDecl *D; SourceLocation Loc; Expr *Base; bool IsArrow:1; // True if this is "X->F", false if this is "X.F". bool IsFreeIvar:1; // True if ivar reference has no base (self assumed). I know we discussed this, but please remind me: how is ObjCIvarRefExpr different from MemberExpr? Is the issue that ObjcIvarDecl is not a FieldDecl or something? Also, are "free" ivars currently being represented with this class or with DeclRefExpr? I think we want to use DeclRefExpr. -Chris From sabre at nondot.org Wed Dec 12 19:59:49 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 01:59:49 -0000 Subject: [cfe-commits] r44976 - in /cfe/trunk: Lex/Lexer.cpp include/clang/Lex/Token.h Message-ID: <200712130159.lBD1xnLK030764@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 19:59:49 2007 New Revision: 44976 URL: http://llvm.org/viewvc/llvm-project?rev=44976&view=rev Log: add a helper method. Modified: cfe/trunk/Lex/Lexer.cpp cfe/trunk/include/clang/Lex/Token.h Modified: cfe/trunk/Lex/Lexer.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Lexer.cpp?rev=44976&r1=44975&r2=44976&view=diff ============================================================================== --- cfe/trunk/Lex/Lexer.cpp (original) +++ cfe/trunk/Lex/Lexer.cpp Wed Dec 12 19:59:49 2007 @@ -51,6 +51,13 @@ return specId ? specId->getObjCKeywordID() : tok::objc_not_keyword; } +/// isNamedIdentifier - Return true if this token is a ppidentifier with the +/// specified name. For example, tok.isNamedIdentifier("this"). +bool Token::isNamedIdentifier(const char *Name) const { + return IdentInfo && !strcmp(IdentInfo->getName(), Name); +} + + //===----------------------------------------------------------------------===// // Lexer Class Implementation //===----------------------------------------------------------------------===// Modified: cfe/trunk/include/clang/Lex/Token.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Token.h?rev=44976&r1=44975&r2=44976&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/Token.h (original) +++ cfe/trunk/include/clang/Lex/Token.h Wed Dec 12 19:59:49 2007 @@ -80,7 +80,11 @@ void setIdentifierInfo(IdentifierInfo *II) { IdentInfo = II; } - + + /// isNamedIdentifier - Return true if this token is a ppidentifier with the + /// specified name. For example, tok.isNamedIdentifier("this"). + bool isNamedIdentifier(const char *Name) const; + /// setFlag - Set the specified flag. void setFlag(TokenFlags Flag) { Flags |= Flag; From sabre at nondot.org Wed Dec 12 20:05:09 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 02:05:09 -0000 Subject: [cfe-commits] r44978 - /cfe/trunk/Parse/ParseObjc.cpp Message-ID: <200712130205.lBD259vZ031175@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 20:05:09 2007 New Revision: 44978 URL: http://llvm.org/viewvc/llvm-project?rev=44978&view=rev Log: use new interface. Modified: cfe/trunk/Parse/ParseObjc.cpp Modified: cfe/trunk/Parse/ParseObjc.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseObjc.cpp?rev=44978&r1=44977&r2=44978&view=diff ============================================================================== --- cfe/trunk/Parse/ParseObjc.cpp (original) +++ cfe/trunk/Parse/ParseObjc.cpp Wed Dec 12 20:05:09 2007 @@ -1282,7 +1282,7 @@ // Parse receiver if (Tok.is(tok::identifier) && (Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope) - || !strcmp(Tok.getIdentifierInfo()->getName(), "super"))) { + || Tok.isNamedIdentifier("super"))) { ReceiverName = Tok.getIdentifierInfo(); ConsumeToken(); } else { From clattner at apple.com Wed Dec 12 20:07:25 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 18:07:25 -0800 Subject: [cfe-commits] r44025 - in /cfe/trunk: Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaExpr.cpp include/clang/Parse/Action.h In-Reply-To: <200711122013.lACKDSSE018960@zion.cs.uiuc.edu> References: <200711122013.lACKDSSE018960@zion.cs.uiuc.edu> Message-ID: <2176E1BC-CF7D-42C0-A8F5-F325A797CF6C@apple.com> On Nov 12, 2007, at 12:13 PM, Fariborz Jahanian wrote: > Author: fjahanian > Date: Mon Nov 12 14:13:27 2007 > New Revision: 44025 > > URL: http://llvm.org/viewvc/llvm-project?rev=44025&view=rev > Log: > 'super' nailed. Hi Fariborz, One thing: > +++ cfe/trunk/Sema/SemaExpr.cpp Mon Nov 12 14:13:27 2007 > @@ -2060,13 +2060,34 @@ > + ObjcInterfaceDecl* ClassDecl = 0; > + if (!strcmp(receiverName->getName(), "super") && CurMethodDecl) { > + ClassDecl = CurMethodDecl->getClassInterface()->getSuperClass(); > + if (CurMethodDecl->isInstance()) { > + IdentifierInfo &II = Context.Idents.get("self"); > + ExprResult ReceiverExpr = ActOnIdentifierExpr(S, lbrac, II, > + false); > + QualType superTy = Context.getObjcInterfaceType(ClassDecl); > + superTy = Context.getPointerType(superTy); > + ReceiverExpr = ActOnCastExpr(SourceLocation(), > superTy.getAsOpaquePtr(), > + SourceLocation(), > ReceiverExpr.Val); > + > + return ActOnInstanceMessage(ReceiverExpr.Val, Sel, lbrac, > rbrac, > + Args); This code appears to be synthesizing a definition of super on the fly. This seems like exactly the same issue as self, etc. Shouldn't it be handled the same way? -Chris From clattner at apple.com Wed Dec 12 22:44:45 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 20:44:45 -0800 Subject: [cfe-commits] r44028 - in /cfe/trunk: AST/StmtPrinter.cpp Sema/SemaExpr.cpp include/clang/AST/Expr.h test/Sema/static-ivar-ref-1.m In-Reply-To: <200711122229.lACMTTI9025355@zion.cs.uiuc.edu> References: <200711122229.lACMTTI9025355@zion.cs.uiuc.edu> Message-ID: On Nov 12, 2007, at 2:29 PM, Fariborz Jahanian wrote: > Author: fjahanian > Date: Mon Nov 12 16:29:28 2007 > New Revision: 44028 > > URL: http://llvm.org/viewvc/llvm-project?rev=44028&view=rev > Log: > Patch to do statically typed ivar references. Hi Fariborz, > +++ cfe/trunk/Sema/SemaExpr.cpp Mon Nov 12 16:29:28 2007 > @@ -519,9 +519,20 @@ > if (ret.isNull()) > return true; > return new OCUVectorElementExpr(ret, BaseExpr, Member, MemberLoc); > + } else if (BaseType->isObjcInterfaceType()) { > + ObjcInterfaceDecl *IFace; > + if (isa(BaseType.getCanonicalType())) > + IFace = dyn_cast(BaseType)->getDecl(); > + else > + IFace = dyn_cast(BaseType) > + ->getInterfaceType()->getDecl(); Code like this could be simplified if ObjcQualifiedInterfaceType inherited from ObjcInterfaceType. Would it make sense to do this? Then the code above would just be: } else if (ObjcInterfaceType *IT = BaseType->getAsObjcInterfaceType()) { ObjcInterfaceDecl *IFace = IT->getDecl(); or something. If you don't think that ObjcQualifiedInterfaceType should derive from ObjcInterfaceType then we need to figure out a better name for "isObjcInterfaceType". I wouldn't expect that to return true for ObjcQualifiedInterfaceType unless ObjcQualifiedInterfaceType derives from ObjcInterfaceType. -Chris From kremenek at apple.com Wed Dec 12 22:47:16 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 04:47:16 -0000 Subject: [cfe-commits] r44982 - in /cfe/trunk/Analysis: LiveVariables.cpp UninitializedValues.cpp Message-ID: <200712130447.lBD4lGn7013532@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 22:47:15 2007 New Revision: 44982 URL: http://llvm.org/viewvc/llvm-project?rev=44982&view=rev Log: Fixed bug in live-variable analysis and uninitialized-values analysis where we incorrectly examine the expression within a sizeof() for use in computing dataflow values. This fixes: PR 1858 (http://llvm.org/bugs/show_bug.cgi?id=1858) Modified: cfe/trunk/Analysis/LiveVariables.cpp cfe/trunk/Analysis/UninitializedValues.cpp Modified: cfe/trunk/Analysis/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/LiveVariables.cpp?rev=44982&r1=44981&r2=44982&view=diff ============================================================================== --- cfe/trunk/Analysis/LiveVariables.cpp (original) +++ cfe/trunk/Analysis/LiveVariables.cpp Wed Dec 12 22:47:15 2007 @@ -93,6 +93,7 @@ Stmt *S = U->getSubExpr(); switch (U->getOpcode()) { + case UnaryOperator::SizeOf: return; case UnaryOperator::PostInc: case UnaryOperator::PostDec: case UnaryOperator::PreInc: Modified: cfe/trunk/Analysis/UninitializedValues.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/UninitializedValues.cpp?rev=44982&r1=44981&r2=44982&view=diff ============================================================================== --- cfe/trunk/Analysis/UninitializedValues.cpp (original) +++ cfe/trunk/Analysis/UninitializedValues.cpp Wed Dec 12 22:47:15 2007 @@ -136,9 +136,19 @@ } bool TransferFuncs::VisitUnaryOperator(UnaryOperator* U) { - if (U->getOpcode() == UnaryOperator::AddrOf) - if (BlockVarDecl* VD = FindBlockVarDecl(U->getSubExpr())) - return V(VD,AD) = Initialized; + switch (U->getOpcode()) { + case UnaryOperator::AddrOf: + if (BlockVarDecl* VD = FindBlockVarDecl(U->getSubExpr())) + return V(VD,AD) = Initialized; + + break; + + case UnaryOperator::SizeOf: + return Initialized; + + default: + break; + } return Visit(U->getSubExpr()); } From sabre at nondot.org Wed Dec 12 23:02:40 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 05:02:40 -0000 Subject: [cfe-commits] r44983 - /cfe/trunk/Basic/LangOptions.cpp Message-ID: <200712130502.lBD52erD014330@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 23:02:35 2007 New Revision: 44983 URL: http://llvm.org/viewvc/llvm-project?rev=44983&view=rev Log: Fix file header. Modified: cfe/trunk/Basic/LangOptions.cpp Modified: cfe/trunk/Basic/LangOptions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/LangOptions.cpp?rev=44983&r1=44982&r2=44983&view=diff ============================================================================== --- cfe/trunk/Basic/LangOptions.cpp (original) +++ cfe/trunk/Basic/LangOptions.cpp Wed Dec 12 23:02:35 2007 @@ -1,4 +1,4 @@ -//===--- SourceManager.cpp - Track and cache source files -----------------===// +//===--- LangOptions.cpp - Language feature info --------------------------===// // // The LLVM Compiler Infrastructure // From clattner at apple.com Wed Dec 12 23:12:16 2007 From: clattner at apple.com (Chris Lattner) Date: Wed, 12 Dec 2007 21:12:16 -0800 Subject: [cfe-commits] r44631 - in /cfe/trunk/Driver: TranslationUnit.cpp TranslationUnit.h In-Reply-To: <200712052136.lB5La8WX021427@zion.cs.uiuc.edu> References: <200712052136.lB5La8WX021427@zion.cs.uiuc.edu> Message-ID: <346DC7D2-3987-4892-BDB4-1F9BE11A63E5@apple.com> On Dec 5, 2007, at 1:36 PM, Ted Kremenek wrote: > Author: kremenek > Date: Wed Dec 5 15:36:08 2007 > New Revision: 44631 > > URL: http://llvm.org/viewvc/llvm-project?rev=44631&view=rev > Log: > Added "TranslationUnit" class that will be used to provide an > interface > for serializing/deserializing ASTs that is decoupled from the logic > in SerializationTest (which will soon be rewritten to use this > interface). Hi Ted, > +++ cfe/trunk/Driver/TranslationUnit.cpp Wed Dec 5 15:36:08 2007 > @@ -0,0 +1,229 @@ > +//===--- TranslationUnit.cpp - Abstraccction for Translation Units > --------===// You're stuttering :) > > +// > +// The LLVM Compiler Infrastructure > +// > +// This file was developed by Ted Kremenek and is distributed under > +// the University of Illinois Open Source License. See LICENSE.TXT > for details. > +// You're missing a divider here. > > +// FIXME: This should eventually be moved out of the driver, or > replaced > +// with its eventual successor. I think this should move to libast? > > +// > +// > = > = > = > ----------------------------------------------------------------------= > ==// > + > +#include "TranslationUnit.h" > +#include "clang.h" > + > +#include "clang/Basic/TargetInfo.h" > +#include "clang/Basic/SourceManager.h" > +#include "clang/AST/AST.h" > + > +#include "llvm/Bitcode/Serialize.h" > +#include "llvm/Bitcode/Deserialize.h" > +#include "llvm/Support/MemoryBuffer.h" > +#include "llvm/System/Path.h" > +#include "llvm/ADT/scoped_ptr.h" > + > +#include Please use > > + > +namespace { > + enum { BasicMetadataBlock = 1, > + ASTContextBlock = 2, > + DeclsBlock = 3 }; > +} > + > +using namespace clang; > + > +bool TranslationUnit::EmitBitcodeFile(llvm::sys::Path& Filename) > const { I don't think this should be a method on TranslationUnit. This should be a global function somewhere that takes a translation unit as an argument. An analog is the LLVM WriteBitcodeToFile function. Please split this out of TranslationUnit.cpp. Likewise for ReadBitcodeFile. > +void TranslationUnit::Emit(llvm::Serializer& Sezr) const { > + > + // ===---------------------------------------------------===/ > + // Serialize the top-level decls. > + // ===---------------------------------------------------===/ > + > + Sezr.EnterBlock(DeclsBlock); > + > + // Only serialize the head of a decl chain. The ASTConsumer > interfaces > + // provides us with each top-level decl, including those nested in > + // a decl chain, so we may be passed decls that are already > serialized. > + for (const_iterator I=begin(), E=end(); I!=E; ++I) > + if (!Sezr.isRegistered(*I)) > + Sezr.EmitOwnedPtr(*I); Funky indentation. > > + > + Sezr.ExitBlock(); > + > + // ===---------------------------------------------------===/ > + // Serialize the "Translation Unit" metadata. > + // ===---------------------------------------------------===/ How about: > + //===---------------------------------------------------===// Takes the same space and is more consistent :) > +++ cfe/trunk/Driver/TranslationUnit.h Wed Dec 5 15:36:08 2007 > @@ -0,0 +1,75 @@ > +//===--- TranslationUnit.h - Abstraction for Translation Units > -----------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file was developed by Ted Kremenek and is distributed under > +// the University of Illinois Open Source License. See LICENSE.TXT > for details. > +// Needs divider here, should also go into AST probably. > > +// FIXME: This should eventually be moved out of the driver, or > replaced > +// with its eventual successor. > +// > +// > = > = > = > ----------------------------------------------------------------------= > ==// > + > +#ifndef LLVM_CLANG_TRANSLATION_UNIT_H > +#define LLVM_CLANG_TRANSLATION_UNIT_H > + > +#include "clang/Basic/LangOptions.h" > +#include "llvm/Bitcode/SerializationFwd.h" > +#include "llvm/System/Path.h" Please forward declare sys::Path instead of #including it. +class TranslationUnit { > + LangOptions LangOpts; > + ASTContext* Context; Can this embed the ASTContext by-value like LangOpts? > > + std::list TopLevelDecls; Please use an std::vector, std::list is really inefficient for this. -Chris From kremenek at apple.com Wed Dec 12 23:14:22 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 05:14:22 -0000 Subject: [cfe-commits] r44984 - /cfe/trunk/Analysis/UninitializedValues.cpp Message-ID: <200712130514.lBD5EMHc014908@zion.cs.uiuc.edu> Author: kremenek Date: Wed Dec 12 23:14:22 2007 New Revision: 44984 URL: http://llvm.org/viewvc/llvm-project?rev=44984&view=rev Log: For uninitialized values analysis, added special treatment for declarations of array types. For things like: char x[10]; we should treat "x" as being initialized, because the variable "x" really refers to the memory block of the array. Clearly x[1] is uninitialized, but expressions like "(char*) x" really do refer to an initialized value. This simple dataflow analysis does not reason about the contents of arrays. This fixes: PR 1859 (http://llvm.org/bugs/show_bug.cgi?id=1859) Modified: cfe/trunk/Analysis/UninitializedValues.cpp Modified: cfe/trunk/Analysis/UninitializedValues.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/UninitializedValues.cpp?rev=44984&r1=44983&r2=44984&view=diff ============================================================================== --- cfe/trunk/Analysis/UninitializedValues.cpp (original) +++ cfe/trunk/Analysis/UninitializedValues.cpp Wed Dec 12 23:14:22 2007 @@ -124,7 +124,22 @@ if (BlockVarDecl* VD = dyn_cast(D)) { if (Stmt* I = VD->getInit()) V(VD,AD) = AD.FullUninitTaint ? V(cast(I),AD) : Initialized; - else V(VD,AD) = Uninitialized; + else { + // Special case for declarations of array types. For things like: + // + // char x[10]; + // + // we should treat "x" as being initialized, because the variable + // "x" really refers to the memory block. Clearly x[1] is + // uninitialized, but expressions like "(char *) x" really do refer to + // an initialized value. This simple dataflow analysis does not reason + // about the contents of arrays, although it could be potentially + // extended to do so if the array were of constant size. + if (VD->getType()->isArrayType()) + V(VD,AD) = Initialized; + else + V(VD,AD) = Uninitialized; + } } return Uninitialized; // Value is never consumed. From sabre at nondot.org Wed Dec 12 23:42:30 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 05:42:30 -0000 Subject: [cfe-commits] r44985 - in /cfe/trunk/www: features.html get_involved.html index.html Message-ID: <200712130542.lBD5gU8o016127@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 12 23:42:27 2007 New Revision: 44985 URL: http://llvm.org/viewvc/llvm-project?rev=44985&view=rev Log: wrap to 80 cols, many fixes to markup. Modified: cfe/trunk/www/features.html cfe/trunk/www/get_involved.html cfe/trunk/www/index.html Modified: cfe/trunk/www/features.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/features.html?rev=44985&r1=44984&r2=44985&view=diff ============================================================================== --- cfe/trunk/www/features.html (original) +++ cfe/trunk/www/features.html Wed Dec 12 23:42:27 2007 @@ -28,7 +28,7 @@

    End-User Features:

    @@ -59,7 +59,7 @@ -

    High Performance and Low Memory Use

    +

    Fast compiles and Low Memory Use

    A major focus of our work on clang is to make it fast, light and scalable. Modified: cfe/trunk/www/get_involved.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_involved.html?rev=44985&r1=44984&r2=44985&view=diff ============================================================================== --- cfe/trunk/www/get_involved.html (original) +++ cfe/trunk/www/get_involved.html Wed Dec 12 23:42:27 2007 @@ -1,99 +1,152 @@ - - - + - - Clang - Get Involved - - + + Clang - Get Involved + + + +

    +

    Getting Involved

    -There are many tasks that are open to new developers who want to get involved with the Clang project. Below, you will find details on how to get started with Clang, plus a few tasks that we need help with.
    -
    -Please note that the information provided here is not completely thorough. This is intentional. If you plan to work on Clang, we would like you to get involved with the other developers. This will allow us to work together better and will give you a better feel for how things are done. -You can talk with other developers at the following mailing list: cfe-dev mailing list. -The clang mailing list is a very friendly place. You can see the archives for records of past discussion. Note that a significant amount of design discussion takes place on the cfe-commits mailing list. + +

    There are many tasks that are open to new developers who want to get involved +with the Clang project. Below, you will find details on how to get started with +Clang, plus a few tasks that we need help with.

    + +

    Please note that the information provided here is not completely thorough. +This is intentional. If you plan to work on Clang, we would like you to get +involved with the other developers. This will allow us to work together better +and will give you a better feel for how things are done.

    + +

    You can talk with other developers at the following mailing list: cfe-dev mailing +list. The clang mailing list is a very friendly place. You can see the +archives for records of past discussion. Note that a significant amount of +design discussion takes place on the cfe-commits mailing +list.

    Getting Started

    +

    A word of warning

    -While this work aims to provide a fully functional C/C++/ObjC front-end, it is still very early work and is under heavy development. In particular, there is no real C++ support yet (this is obviously a big project), and C/ObjC support is still missing some features. Some of the more notable missing pieces of C support are: + +

    While this work aims to provide a fully functional C/C++/ObjC front-end, it +is still very early work and is under heavy development. In particular, +there is no real C++ support yet (this is obviously a big project), and C/ObjC +support is still missing some features. Some of the more notable missing pieces +of C support are:

    +
      -
    1. The semantic analyzer does not produce all of the warnings and errors it should. -
    2. The LLVM code generator is still very early on. It does not support many important things, like any support for structs and unions. That said, it does handle scalar operations and vectors. clang is not ready to be used as a general purpose C code generator yet. -
    3. We don't consider the API to be stable yet, and reserve the right to change fundamental things :) +
    4. The semantic analyzer does not produce all of the warnings and errors it + should.
    5. +
    6. The LLVM code generator is still very early on. It does not support many + important things, like any support for structs and unions. That said, it + does handle scalar operations and vectors. clang is not ready to be used + as a general purpose C code generator yet.
    7. +
    8. We don't consider the API to be stable yet, and reserve the right to + change fundamental things. :)
    -Our plan is to continue chipping away at these issues until C works really well, but we'd love help from other interested contributors. + +

    Our plan is to continue chipping away at these issues until C works really +well, but we'd love help from other interested contributors.

    Follow what's going on

    -Clang is a subproject of the LLVM Project, but has -its own mailing lists because the communities have people with different +

    Clang is a subproject of the LLVM Project, but +has its own mailing lists because the communities have people with different interests. If you are interested in clang only, these two lists should be all you need. If you are interested in the LLVM optimizer and code generator, please consider signing up for llvmdev and llvm-commits -as well.
    +as well.

    +
      -
    • cfe-commits - This list is for patch submission/discussion. -
    • cfe-dev - This list is for everything else clang related. +
    • cfe-commits + - This list is for patch submission/discussion.
    • + +
    • cfe-dev - +This list is for everything else clang related.
    -

    Building clang / working with the code 

    -If you would like to check out and build the project, the current scheme is:

    + +

    Building clang / working with the code

    + +

    If you would like to check out and build the project, the current scheme +is:

      -
    1. Checkout and build LLVM - (latest - instructions for SVN access)
    2. -
        -
      • svn co http://llvm.org/svn/llvm-project/llvm/trunk - llvm
      • -
      • cd llvm
      • -
      • ./configure; make
      • -
      -
    3. Checkout clang
    4. -
        -
      • From within the llvm directory (where you - built llvm):
      • -
      • cd llvm/tools -
      • svn co - http://llvm.org/svn/llvm-project/cfe/trunk clang
      • - -
      -
    5. Non-mac users: Paths to system header files are currently hard coded - into clang; as a result, if clang can't find your system headers, - please follow these instructions: -
        -
      • 'touch empty.c; gcc -v empty.c -fsyntax-only' to get the path. -
      • Look for the comment "FIXME: temporary hack: - hard-coded paths" in clang/Driver/clang.cpp and - change the lines below to include that path. -
      -
    6. Build clang
    7. -
        -
      • cd clang (assuming that you are in llvm/tools)
      • -
      • make
      • -
      +
    8. Checkout + and build LLVM from SVN head:
    9. + +
        +
      • svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
      • +
      • cd llvm
      • +
      • ./configure; make
      • +
      +
    10. Checkout clang:
    11. +
        +
      • From within the llvm directory (where you + built llvm):
      • +
      • cd llvm/tools +
      • svn co + http://llvm.org/svn/llvm-project/cfe/trunk clang
      • + +
      +
    12. Non-mac users: Paths to system header files are currently hard coded + into clang; as a result, if clang can't find your system headers, + please follow these instructions:
    13. + +
        +
      • 'touch empty.c; gcc -v empty.c -fsyntax-only' to get the + path.
      • +
      • Look for the comment "FIXME: temporary hack: + hard-coded paths" in clang/Driver/clang.cpp and + change the lines below to include that path.
      • +
      + +
    14. Build clang:
    15. +
        +
      • cd clang (assuming that you are in llvm/tools)
      • +
      • make
      • +
      + +
    16. Try it out (assuming you add llvm/Debug/bin to your path):
    17. +
        +
      • clang --help
      • +
      • clang file.c -fsyntax-only (check for correctness)
      • +
      • clang file.c -ast-dump (internal debug dump of ast)
      • +
      • clang file.c -ast-view (set up graphviz + and rebuild llvm first)
      • +
      • clang file.c -emit-llvm (print out unoptimized llvm code)
      • +
      • clang file.c -emit-llvm | llvm-as | opt -std-compile-opts | + llvm-dis (print out optimized llvm code)
      • +
      • clang file.c -emit-llvm | llvm-as | opt -std-compile-opts | llc + > file.s (output native machine code)
      • +
    -

    Note that the C front-end uses LLVM, but does not depend on llvm-gcc. If you encounter problems with building clang, make sure you have the latest SVN version of LLVM. LLVM contains support libraries for clang that will be updated as well as - development on clang progresses.


    - -

    We will eventually integrate this better as a sub-project, but for now it builds a single tool named 'clang'.
    -Once llvm is built in this way, you can compile C code. + development on clang progresses.

    +

    Examples of using clang

    -The clang driver takes a lot of GCC compatible options, which you can see with 'clang --help'. Here are a few examples: - + +

    The clang driver takes a lot of GCC compatible options, which you can see +with 'clang --help'. Here are a few examples:

    + +
     $ cat ~/t.c
     
    @@ -133,13 +186,11 @@
     
     LLVM code generation:
     $ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llvm-dis
    -define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
    +define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
     entry:
    -         %mul = mul <4 x float> %b, %a           ; <<4 x float>>  
    -[#uses=1]
    -         %add = add <4 x float> %mul, %a         ; <<4 x float>>  
    -[#uses=1]
    -         ret <4 x float> %add
    +         %mul = mul <4 x float> %b, %a
    +         %add = add <4 x float> %mul, %a
    +         ret <4 x float> %add
     }
     $ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc - 
     march=ppc32 -mcpu=g5
    
    Modified: cfe/trunk/www/index.html
    URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/index.html?rev=44985&r1=44984&r2=44985&view=diff
    
    ==============================================================================
    --- cfe/trunk/www/index.html (original)
    +++ cfe/trunk/www/index.html Wed Dec 12 23:42:27 2007
    @@ -28,7 +28,7 @@
       

    End-User Features:

      -
    • High performance and low memory use
    • +
    • Fast compiles and low memory use
    • Expressive diagnostics
    • GCC compatibility
    From sabre at nondot.org Thu Dec 13 00:20:16 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 06:20:16 -0000 Subject: [cfe-commits] r44988 - in /cfe/trunk/www: get_involved.html get_started.html index.html menu.html.incl Message-ID: <200712130620.lBD6KGWG021355@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 00:20:15 2007 New Revision: 44988 URL: http://llvm.org/viewvc/llvm-project?rev=44988&view=rev Log: split get_involved into two pages: get_started and get_involved. Added: cfe/trunk/www/get_started.html Modified: cfe/trunk/www/get_involved.html cfe/trunk/www/index.html cfe/trunk/www/menu.html.incl Modified: cfe/trunk/www/get_involved.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_involved.html?rev=44988&r1=44987&r2=44988&view=diff ============================================================================== --- cfe/trunk/www/get_involved.html (original) +++ cfe/trunk/www/get_involved.html Thu Dec 13 00:20:15 2007 @@ -13,206 +13,73 @@
    -

    Getting Involved

    +

    Getting Involved with the Clang Project

    -

    There are many tasks that are open to new developers who want to get involved -with the Clang project. Below, you will find details on how to get started with -Clang, plus a few tasks that we need help with.

    +

    Once you have checked out and built clang and +played around with it, you might be wondering what you can do to make it better +and contribute to its development. Alternatively, maybe you just want to follow +the development of the project to see it progress. +

    -

    Please note that the information provided here is not completely thorough. -This is intentional. If you plan to work on Clang, we would like you to get -involved with the other developers. This will allow us to work together better -and will give you a better feel for how things are done.

    +

    Follow what's going on

    -

    You can talk with other developers at the following mailing list: cfe-dev mailing -list. The clang mailing list is a very friendly place. You can see the -archives for records of past discussion. Note that a significant amount of -design discussion takes place on the cfe-commits mailing -list.

    - -

    Getting Started

    - -

    A word of warning

    +

    Clang is a subproject of the LLVM Project, but +has its own mailing lists because the communities have people with different +interests. The two clang lists are:

    -

    While this work aims to provide a fully functional C/C++/ObjC front-end, it -is still very early work and is under heavy development. In particular, -there is no real C++ support yet (this is obviously a big project), and C/ObjC -support is still missing some features. Some of the more notable missing pieces -of C support are:

    - -
      -
    1. The semantic analyzer does not produce all of the warnings and errors it - should.
    2. -
    3. The LLVM code generator is still very early on. It does not support many - important things, like any support for structs and unions. That said, it - does handle scalar operations and vectors. clang is not ready to be used - as a general purpose C code generator yet.
    4. -
    5. We don't consider the API to be stable yet, and reserve the right to - change fundamental things. :)
    6. -
    +
      +
    • cfe-commits + - This list is for patch submission/discussion.
    • -

      Our plan is to continue chipping away at these issues until C works really -well, but we'd love help from other interested contributors.

      +
    • cfe-dev - +This list is for everything else clang related (questions and answers, bug +reports, etc).
    • -

      Follow what's going on

      +
    -

    Clang is a subproject of the LLVM Project, but -has its own mailing lists because the communities have people with different -interests. If you are interested in clang only, these two lists should be all +

    If you are interested in clang only, these two lists should be all you need. If you are interested in the LLVM optimizer and code generator, please consider signing up for llvmdev and llvm-commits as well.

    -
      -
    • cfe-commits - - This list is for patch submission/discussion.
    • -
    • cfe-dev - -This list is for everything else clang related.
    • -
    +

    The best way to talk with other developers on the project is through the cfe-dev mailing +list. The clang mailing list is a very friendly place and we welcome +newcomers. In addition to the cfe-dev list, a significant amount of design +discussion takes place on the cfe-commits mailing +list. All of these lists have archives, so you can browse through previous +discussions or follow the list development on the web if you prefer.

    + -

    Building clang / working with the code

    +

    Open Projects

    -

    If you would like to check out and build the project, the current scheme -is:

    +

    Here are a few tasks that are available for newcomers to work on. This list +is provided to generate ideas, it is not intended to be comprehensive. Please +ask on cfe-dev for more specifics or to verify that one of these isn't already +completed. :)

    + +

    Please note that the information provided here is not completely thorough. +This is intentional. If you plan to work on Clang, we would like you to get +involved with the other developers. This will allow us to work together better +and will give you a better feel for how things are done.

    -
      -
    1. Checkout - and build LLVM from SVN head:
    2. - -
        -
      • svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
      • -
      • cd llvm
      • -
      • ./configure; make
      • -
      -
    3. Checkout clang:
    4. -
        -
      • From within the llvm directory (where you - built llvm):
      • -
      • cd llvm/tools -
      • svn co - http://llvm.org/svn/llvm-project/cfe/trunk clang
      • - -
      -
    5. Non-mac users: Paths to system header files are currently hard coded - into clang; as a result, if clang can't find your system headers, - please follow these instructions:
    6. - -
        -
      • 'touch empty.c; gcc -v empty.c -fsyntax-only' to get the - path.
      • -
      • Look for the comment "FIXME: temporary hack: - hard-coded paths" in clang/Driver/clang.cpp and - change the lines below to include that path.
      • -
      - -
    7. Build clang:
    8. -
        -
      • cd clang (assuming that you are in llvm/tools)
      • -
      • make
      • -
      - -
    9. Try it out (assuming you add llvm/Debug/bin to your path):
    10. -
        -
      • clang --help
      • -
      • clang file.c -fsyntax-only (check for correctness)
      • -
      • clang file.c -ast-dump (internal debug dump of ast)
      • -
      • clang file.c -ast-view (set up graphviz - and rebuild llvm first)
      • -
      • clang file.c -emit-llvm (print out unoptimized llvm code)
      • -
      • clang file.c -emit-llvm | llvm-as | opt -std-compile-opts | - llvm-dis (print out optimized llvm code)
      • -
      • clang file.c -emit-llvm | llvm-as | opt -std-compile-opts | llc - > file.s (output native machine code)
      • -
      -
    - -

    Note that the C front-end uses LLVM, but does not depend on - llvm-gcc. If you encounter problems with building clang, make - sure you have the latest SVN version of LLVM. LLVM contains - support libraries for clang that will be updated as well as - development on clang progresses.

    - -

    Examples of using clang

    - -

    The clang driver takes a lot of GCC compatible options, which you can see -with 'clang --help'. Here are a few examples:

    - - -
    -$ cat ~/t.c
    -
    -typedef float V __attribute__((vector_size(16)));
    -V foo(V a, V b) { return a+b*a; }
    -
    -Preprocessing:
    -$ clang ~/t.c -E
    -# 1 "/Users/sabre/t.c" 1
    -
    -typedef float V __attribute__((vector_size(16)));
    -
    -V foo(V a, V b) { return a+b*a; }
    -
    -
    -Type checking:
    -$ clang -fsyntax-only ~/t.c
    -
    -
    -GCC options:
    -$ clang -fsyntax-only ~/t.c -pedantic
    -/Users/sabre/t.c:2:17: warning: extension used
    -typedef float V __attribute__((vector_size(16)));
    -                ^
    -1 diagnostic generated.
    -
    -
    -
    -Pretty printing from the AST:
    -$ clang ~/t.c -ast-print
    -typedef float V __attribute__(( vector_size(16) ));
    -
    -V foo(V a, V b) {
    -   return a + b * a;
    -}
    -
    -
    -LLVM code generation:
    -$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llvm-dis
    -define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
    -entry:
    -         %mul = mul <4 x float> %b, %a
    -         %add = add <4 x float> %mul, %a
    -         ret <4 x float> %add
    -}
    -$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc - 
    -march=ppc32 -mcpu=g5
    -..
    -_foo:
    -         vmaddfp v2, v3, v2, v2
    -         blr
    -$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc - 
    -march=x86 -mcpu=yonah
    -..
    -_foo:
    -         mulps %xmm0, %xmm1
    -         addps %xmm0, %xmm1
    -         movaps %xmm1, %xmm0
    -         ret
    -
    -

    Available tasks

    -Here are a few tasks that are currently available for newcomers to work on:
      -
    • None yet, ask on cfe-dev
    • +
    • Compile your favorite C/ObjC project with "clang -fsyntax-only": +the clang type checker and verifier is quite close to complete (but not bug +free!) for C and Objective C. We appreciate all reports of code that is +rejected by the front-end, and if you notice invalid code that is not rejected +by clang, that is also very important to us.
    • + +
    • + +
    +
    Added: cfe/trunk/www/get_started.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_started.html?rev=44988&view=auto ============================================================================== --- cfe/trunk/www/get_started.html (added) +++ cfe/trunk/www/get_started.html Thu Dec 13 00:20:15 2007 @@ -0,0 +1,192 @@ + + + + + Clang - Getting Started + + + + + + + +
    + +

    Getting Started: Building and Running Clang

    + + +

    This page gives you the shortest path to checking out clang and demos a few +options. This should get you up and running with the minimum of muss and fuss. +If you like what you see, please consider getting +involved with the clang community.

    + + +

    A word of warning

    + +

    While this work aims to provide a fully functional C/C++/ObjC front-end, it +is still very early work and is under heavy development. In particular, +there is no real C++ support yet (this is obviously a big project), and C/ObjC +support is still missing some features. Some of the more notable missing pieces +of C support are:

    + +
      +
    1. The semantic analyzer does not produce all of the warnings and errors it + should.
    2. +
    3. The LLVM code generator is still missing important features. clang is not + ready to be used as a general purpose C code generator yet, but if you + hit problems and report them to cfe-dev, we'll fix them :).
    4. +
    5. We don't consider the API to be stable yet, and reserve the right to + change fundamental things.
    6. +
    + +

    Our plan is to continue chipping away at these issues until C works really +well, but we'd love help from other interested contributors. We expect C to be +in good shape by mid to late 2008.

    + +

    Building clang / working with the code

    + +

    If you would like to check out and build the project, the current scheme +is:

    + +
      +
    1. Checkout + and build LLVM from SVN head:
    2. + +
        +
      • svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
      • +
      • cd llvm
      • +
      • ./configure; make
      • +
      +
    3. Checkout clang:
    4. +
        +
      • From within the llvm directory (where you + built llvm):
      • +
      • cd llvm/tools +
      • svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
      • + +
      +
    5. Non-mac users: Paths to system header files are currently hard coded + into clang; as a result, if clang can't find your system headers, + please follow these instructions:
    6. + +
        +
      • 'touch empty.c; gcc -v empty.c -fsyntax-only' to get the + path.
      • +
      • Look for the comment "FIXME: temporary hack: + hard-coded paths" in clang/Driver/clang.cpp and + change the lines below to include that path.
      • +
      + +
    7. Build clang:
    8. +
        +
      • cd clang (assuming that you are in llvm/tools)
      • +
      • make (this will give you a debug build)
      • +
      + +
    9. Try it out (assuming you add llvm/Debug/bin to your path):
    10. +
        +
      • clang --help
      • +
      • clang file.c -fsyntax-only (check for correctness)
      • +
      • clang file.c -ast-dump (internal debug dump of ast)
      • +
      • clang file.c -ast-view (set up graphviz + and rebuild llvm first)
      • +
      • clang file.c -emit-llvm (print out unoptimized llvm code)
      • +
      • clang file.c -emit-llvm | llvm-as | opt -std-compile-opts | + llvm-dis (print out optimized llvm code)
      • +
      • clang file.c -emit-llvm | llvm-as | opt -std-compile-opts | llc + > file.s (output native machine code)
      • +
      +
    + +

    Note that the C front-end uses LLVM, but does not depend on + llvm-gcc. If you encounter problems with building clang, make + sure you have the latest SVN version of LLVM. LLVM contains + support libraries for clang that will be updated as well as + development on clang progresses.

    + +

    Examples of using clang

    + +

    The clang driver takes a lot of GCC compatible options, which you can see +with 'clang --help'. Here are a few examples:

    + + +
    +$ cat ~/t.c
    +typedef float V __attribute__((vector_size(16)));
    +V foo(V a, V b) { return a+b*a; }
    +
    + + +

    Preprocessing:

    + +
    +$ clang ~/t.c -E
    +# 1 "/Users/sabre/t.c" 1
    +
    +typedef float V __attribute__((vector_size(16)));
    +
    +V foo(V a, V b) { return a+b*a; }
    +
    + + +

    Type checking:

    + +
    +$ clang -fsyntax-only ~/t.c
    +
    + + +

    GCC options:

    + +
    +$ clang -fsyntax-only ~/t.c -pedantic
    +/Users/sabre/t.c:2:17: warning: extension used
    +typedef float V __attribute__((vector_size(16)));
    +                ^
    +1 diagnostic generated.
    +
    + + +

    Pretty printing from the AST:

    + +
    +$ clang ~/t.c -ast-print
    +typedef float V __attribute__(( vector_size(16) ));
    +V foo(V a, V b) {
    +   return a + b * a;
    +}
    +
    + + +

    Code generation with LLVM:

    + +
    +$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llvm-dis
    +define <4 x float> @foo(<4 x float> %a, <4 x float> %b) {
    +entry:
    +         %mul = mul <4 x float> %b, %a
    +         %add = add <4 x float> %mul, %a
    +         ret <4 x float> %add
    +}
    +$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc -march=ppc32 -mcpu=g5
    +..
    +_foo:
    +         vmaddfp v2, v3, v2, v2
    +         blr
    +$ clang ~/t.c -emit-llvm | llvm-as | opt -std-compile-opts | llc -march=x86 -mcpu=yonah
    +..
    +_foo:
    +         mulps %xmm0, %xmm1
    +         addps %xmm0, %xmm1
    +         movaps %xmm1, %xmm0
    +         ret
    +
    + +
    + + Modified: cfe/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/index.html?rev=44988&r1=44987&r2=44988&view=diff ============================================================================== --- cfe/trunk/www/index.html (original) +++ cfe/trunk/www/index.html Thu Dec 13 00:20:15 2007 @@ -17,7 +17,8 @@

    The goal of the Clang project is to create a new C, C++, Objective C and Objective C++ front-end for the LLVM - compiler.

    + compiler. You can get and build the source + today.

    Features and Goals

    @@ -38,7 +39,8 @@
    • Modular library based architecture
    • -
    • Support diverse clients (refactoring, static analysis, code generation, etc)
    • +
    • Support diverse clients (refactoring, static analysis, code generation, + etc)
    • Allow tight integration with IDEs
    • Use the LLVM 'BSD' License
    @@ -98,18 +100,19 @@ respectable C++ support for another 2 years or so.

    -

    Get Involved

    +

    Get it and get involved!

    -

    The developers of Clang include contributers from Apple and numerous - other volunteers. If you are interested in joining the community or - learning more, please consider joining the cfe-dev - mailing list, or start by browsing its archives.

    - -

    If you are interested in trying out Clang, please see the build - instructions on the Get Involved - page.

    +

    Start by geting the code, building it, and + playing with it. This will show you the sorts of things we can do + today and will let you have the "clang experience" first hand: hopefully + it will "resonate" with you. :)

    + +

    Once you've done that, please consider getting + involved in the clang community. The clang developers include numerous + volunteers as well as contributers from Apple. If you're interested in + following the development of clang, signing up for a mailing list is a good + way to learn about how the project works.

    Modified: cfe/trunk/www/menu.html.incl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/menu.html.incl?rev=44988&r1=44987&r2=44988&view=diff ============================================================================== --- cfe/trunk/www/menu.html.incl (original) +++ cfe/trunk/www/menu.html.incl Thu Dec 13 00:20:15 2007 @@ -8,8 +8,9 @@ About Features Comparisons - Get Involved - Manual + Get Started + Get Involved + clang Internals
  • From sabre at nondot.org Thu Dec 13 00:55:02 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 06:55:02 -0000 Subject: [cfe-commits] r44991 - /cfe/trunk/www/status.html Message-ID: <200712130655.lBD6t2if025471@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 00:55:02 2007 New Revision: 44991 URL: http://llvm.org/viewvc/llvm-project?rev=44991&view=rev Log: nuke hte status page. Removed: cfe/trunk/www/status.html Removed: cfe/trunk/www/status.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/status.html?rev=44990&view=auto ============================================================================== --- cfe/trunk/www/status.html (original) +++ cfe/trunk/www/status.html (removed) @@ -1,151 +0,0 @@ - - - - - - Status of Clang - - - - - - -
    -

    Status of Clang

    - Here is a rundown of the current status of Clang as of September 2007. -

    By Language:

    - - - - - - - - - - - - - - - - - - - - - - -
    CBasic Status
    -
      -
    • Add some notes here. -
    • Add some notes here. -
    -
    Obj CBasic Status
    -
      -
    • Add some notes here. -
    • Add some notes here. -
    -
    C++Basic Status
    -
      -
    • Add some notes here. -
    • Add some notes here. -
    -
    -

    By Library:

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    LibraryCObj CC++
    libsupportBasic StatusBasic StatusBasic Status
    libsystemBasic StatusBasic StatusBasic Status
    libbasic
    libast
    liblex
    libparse
    libsema
    libcodegen
    clang
    -

    Status History (notes):

    -

    October 5, 2007

    - -

    July 17, 2007

    - -
    - - \ No newline at end of file From sabre at nondot.org Thu Dec 13 00:55:59 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 06:55:59 -0000 Subject: [cfe-commits] r44992 - /cfe/trunk/www/content.css Message-ID: <200712130656.lBD6u0LY025550@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 00:55:59 2007 New Revision: 44992 URL: http://llvm.org/viewvc/llvm-project?rev=44992&view=rev Log: remove some dead styles. Modified: cfe/trunk/www/content.css Modified: cfe/trunk/www/content.css URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/content.css?rev=44992&r1=44991&r2=44992&view=diff ============================================================================== --- cfe/trunk/www/content.css (original) +++ cfe/trunk/www/content.css Thu Dec 13 00:55:59 2007 @@ -8,19 +8,3 @@ margin-left: auto; margin-right: auto } - - -/* FIXME: This is only for the status page */ -table,tr,td { - border:.3ex solid black; - border-collapse:collapse; - padding:.4ex; -} - -.code { - font:Courier,Arial; -} -.simple_list { /* simple lists that don't need to stand out */ - margin-left:0; -} - From sabre at nondot.org Thu Dec 13 01:28:16 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 07:28:16 -0000 Subject: [cfe-commits] r44993 - in /cfe/trunk: Sema/SemaExpr.cpp test/Sema/shift.c Message-ID: <200712130728.lBD7SHjv026972@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 01:28:16 2007 New Revision: 44993 URL: http://llvm.org/viewvc/llvm-project?rev=44993&view=rev Log: Don't do integer promotions of LHS for compound shift assignment. The LHS has to be a modifiable lvalue. Added: cfe/trunk/test/Sema/shift.c Modified: cfe/trunk/Sema/SemaExpr.cpp Modified: cfe/trunk/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=44993&r1=44992&r2=44993&view=diff ============================================================================== --- cfe/trunk/Sema/SemaExpr.cpp (original) +++ cfe/trunk/Sema/SemaExpr.cpp Thu Dec 13 01:28:16 2007 @@ -1321,7 +1321,8 @@ // Shifts don't perform usual arithmetic conversions, they just do integer // promotions on each operand. C99 6.5.7p3 - UsualUnaryConversions(lex); + if (!isCompAssign) + UsualUnaryConversions(lex); UsualUnaryConversions(rex); // "The type of the result is that of the promoted left operand." Added: cfe/trunk/test/Sema/shift.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/shift.c?rev=44993&view=auto ============================================================================== --- cfe/trunk/test/Sema/shift.c (added) +++ cfe/trunk/test/Sema/shift.c Thu Dec 13 01:28:16 2007 @@ -0,0 +1,6 @@ +// RUN: clang -fsyntax-only %s + +void test() { + char c; + c <<= 14; +} From sabre at nondot.org Thu Dec 13 01:34:23 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 07:34:23 -0000 Subject: [cfe-commits] r44994 - /cfe/trunk/CodeGen/CGBuiltin.cpp Message-ID: <200712130734.lBD7YNgr027202@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 01:34:23 2007 New Revision: 44994 URL: http://llvm.org/viewvc/llvm-project?rev=44994&view=rev Log: simplify some code. Modified: cfe/trunk/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=44994&r1=44993&r2=44994&view=diff ============================================================================== --- cfe/trunk/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/CodeGen/CGBuiltin.cpp Thu Dec 13 01:34:23 2007 @@ -21,10 +21,8 @@ #include "llvm/Constants.h" #include "llvm/Function.h" #include "llvm/Intrinsics.h" - using namespace clang; using namespace CodeGen; - using namespace llvm; RValue CodeGenFunction::EmitBuiltinExpr(unsigned BuiltinID, const CallExpr *E) { @@ -34,7 +32,7 @@ return EmitCallExpr(CGM.getBuiltinLibFunction(BuiltinID), E); // See if we have a target specific intrinsic. - llvm::Intrinsic::ID IntrinsicID; + Intrinsic::ID IntrinsicID; const char *TargetPrefix = Target.getTargetPrefix(); const char *BuiltinName = getContext().BuiltinInfo.GetName(BuiltinID); #define GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN @@ -42,15 +40,13 @@ #undef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN if (IntrinsicID != Intrinsic::not_intrinsic) { - llvm::SmallVector Args; - - llvm::Function *F = llvm::Intrinsic::getDeclaration(&CGM.getModule(), - IntrinsicID); + SmallVector Args; + Function *F = Intrinsic::getDeclaration(&CGM.getModule(), IntrinsicID); const llvm::FunctionType *FTy = F->getFunctionType(); for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) { - llvm::Value *ArgValue = EmitScalarExpr(E->getArg(i)); + Value *ArgValue = EmitScalarExpr(E->getArg(i)); // If the intrinsic arg type is different from the builtin arg type // we need to do a bit cast. @@ -64,17 +60,15 @@ Args.push_back(ArgValue); } - llvm::Value *V = Builder.CreateCall(F, &Args[0], &Args[0] + Args.size()); - + Value *V = Builder.CreateCall(F, &Args[0], &Args[0] + Args.size()); QualType BuiltinRetType = E->getType(); - const llvm::Type *RetTy = BuiltinRetType->isVoidType() ? - llvm::Type::VoidTy : ConvertType(BuiltinRetType); + const llvm::Type *RetTy = llvm::Type::VoidTy; + if (!BuiltinRetType->isVoidType()) RetTy = ConvertType(BuiltinRetType); if (RetTy != V->getType()) { assert(V->getType()->canLosslesslyBitCastTo(RetTy) && "Must be able to losslessly bit cast result type"); - V = Builder.CreateBitCast(V, RetTy); } @@ -82,7 +76,7 @@ } // See if we have a target specific builtin that needs to be lowered. - llvm::Value *V = 0; + Value *V = 0; if (strcmp(TargetPrefix, "x86") == 0) V = EmitX86BuiltinExpr(BuiltinID, E); @@ -97,7 +91,7 @@ // Unknown builtin, for now just dump it out and return undef. if (hasAggregateLLVMType(E->getType())) return RValue::getAggregate(CreateTempAlloca(ConvertType(E->getType()))); - return RValue::get(llvm::UndefValue::get(ConvertType(E->getType()))); + return RValue::get(UndefValue::get(ConvertType(E->getType()))); } case Builtin::BI__builtin___CFStringMakeConstantString: { const Expr *Arg = E->getArg(0); @@ -118,86 +112,73 @@ } case Builtin::BI__builtin_va_start: case Builtin::BI__builtin_va_end: { - llvm::Value *ArgValue = EmitScalarExpr(E->getArg(0)); + Value *ArgValue = EmitScalarExpr(E->getArg(0)); const llvm::Type *DestType = llvm::PointerType::get(llvm::Type::Int8Ty); if (ArgValue->getType() != DestType) ArgValue = Builder.CreateBitCast(ArgValue, DestType, ArgValue->getNameStart()); - llvm::Intrinsic::ID inst = (BuiltinID == Builtin::BI__builtin_va_start) ? - llvm::Intrinsic::vastart : llvm::Intrinsic::vaend; - llvm::Value *F = llvm::Intrinsic::getDeclaration(&CGM.getModule(), inst); - llvm::Value *V = Builder.CreateCall(F, ArgValue); + Intrinsic::ID inst = (BuiltinID == Builtin::BI__builtin_va_start) ? + Intrinsic::vastart : Intrinsic::vaend; + Value *F = Intrinsic::getDeclaration(&CGM.getModule(), inst); + Value *V = Builder.CreateCall(F, ArgValue); return RValue::get(V); } case Builtin::BI__builtin_classify_type: { - llvm::APSInt Result(32); + APSInt Result(32); if (!E->isBuiltinClassifyType(Result)) assert(0 && "Expr not __builtin_classify_type!"); - return RValue::get(llvm::ConstantInt::get(Result)); + return RValue::get(ConstantInt::get(Result)); } case Builtin::BI__builtin_constant_p: { - llvm::APSInt Result(32); + APSInt Result(32); // FIXME: Analyze the parameter and check if it is a constant. Result = 0; - return RValue::get(llvm::ConstantInt::get(Result)); + return RValue::get(ConstantInt::get(Result)); } case Builtin::BI__builtin_abs: { - llvm::Value *ArgValue = EmitScalarExpr(E->getArg(0)); + Value *ArgValue = EmitScalarExpr(E->getArg(0)); llvm::BinaryOperator *NegOp = Builder.CreateNeg(ArgValue, (ArgValue->getName() + "neg").c_str()); - llvm::Value *CmpResult = + Value *CmpResult = Builder.CreateICmpSGE(ArgValue, NegOp->getOperand(0), "abscond"); - llvm::Value *Result = + Value *Result = Builder.CreateSelect(CmpResult, ArgValue, NegOp, "abs"); return RValue::get(Result); } - case Builtin::BI__builtin_expect: { - llvm::Value *Condition = EmitScalarExpr(E->getArg(0)); - return RValue::get(Condition); - } + case Builtin::BI__builtin_expect: + return RValue::get(EmitScalarExpr(E->getArg(0))); case Builtin::BI__builtin_bswap32: case Builtin::BI__builtin_bswap64: { - llvm::Value *ArgValue = EmitScalarExpr(E->getArg(0)); + Value *ArgValue = EmitScalarExpr(E->getArg(0)); const llvm::Type *ArgType = ArgValue->getType(); - llvm::Value *F = - llvm::Intrinsic::getDeclaration(&CGM.getModule(), - llvm::Intrinsic::bswap, - &ArgType, 1); - llvm::Value *V = Builder.CreateCall(F, ArgValue, "tmp"); - - return RValue::get(V); + Value *F = Intrinsic::getDeclaration(&CGM.getModule(), Intrinsic::bswap, + &ArgType, 1); + return RValue::get(Builder.CreateCall(F, ArgValue, "tmp")); } case Builtin::BI__builtin_inff: { - llvm::APFloat f(llvm::APFloat::IEEEsingle, - llvm::APFloat::fcInfinity, false); - - llvm::Value *V = llvm::ConstantFP::get(llvm::Type::FloatTy, f); - return RValue::get(V); + APFloat f(APFloat::IEEEsingle, APFloat::fcInfinity, false); + return RValue::get(ConstantFP::get(llvm::Type::FloatTy, f)); } case Builtin::BI__builtin_inf: // FIXME: mapping long double onto double. case Builtin::BI__builtin_infl: { - llvm::APFloat f(llvm::APFloat::IEEEdouble, - llvm::APFloat::fcInfinity, false); - - llvm::Value *V = llvm::ConstantFP::get(llvm::Type::DoubleTy, f); - return RValue::get(V); + APFloat f(APFloat::IEEEdouble, APFloat::fcInfinity, false); + return RValue::get(ConstantFP::get(llvm::Type::DoubleTy, f)); } } return RValue::get(0); } -llvm::Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, - const CallExpr *E) -{ +Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, + const CallExpr *E) { switch (BuiltinID) { default: return 0; case X86::BI__builtin_ia32_mulps: @@ -217,7 +198,7 @@ EmitScalarExpr(E->getArg(1)), "pxor"); case X86::BI__builtin_ia32_pandn: { - llvm::Value *V1 = Builder.CreateNot(EmitScalarExpr(E->getArg(0)), "tmp"); + Value *V1 = Builder.CreateNot(EmitScalarExpr(E->getArg(0)), "tmp"); return Builder.CreateAnd(V1, EmitScalarExpr(E->getArg(1)), "pandn"); } case X86::BI__builtin_ia32_paddb: @@ -266,9 +247,9 @@ 0, 2, "punpckldq"); case X86::BI__builtin_ia32_pshufd: { - llvm::Value *V = EmitScalarExpr(E->getArg(0)); - llvm::ConstantInt *I = - cast(EmitScalarExpr(E->getArg(1))); + Value *V = EmitScalarExpr(E->getArg(0)); + ConstantInt *I = + cast(EmitScalarExpr(E->getArg(1))); int i = I->getZExtValue(); return EmitShuffleVector(V, V, @@ -279,9 +260,8 @@ } } -llvm::Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, - const CallExpr *E) -{ +Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, + const CallExpr *E) { switch (BuiltinID) { default: return 0; } From sabre at nondot.org Thu Dec 13 01:41:58 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 07:41:58 -0000 Subject: [cfe-commits] r44995 - /cfe/trunk/include/clang/AST/Builtins.def Message-ID: <200712130741.lBD7fw2R027818@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 01:41:58 2007 New Revision: 44995 URL: http://llvm.org/viewvc/llvm-project?rev=44995&view=rev Log: add some builtins. Modified: cfe/trunk/include/clang/AST/Builtins.def Modified: cfe/trunk/include/clang/AST/Builtins.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Builtins.def?rev=44995&r1=44994&r2=44995&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Builtins.def (original) +++ cfe/trunk/include/clang/AST/Builtins.def Thu Dec 13 01:41:58 2007 @@ -62,6 +62,14 @@ BUILTIN(__builtin_fabsf, "ff" , "ncF") BUILTIN(__builtin_fabsl, "LdLd", "ncF") +// FP Comparisons. +BUILTIN(__builtin_isgreater , "i.", "nc") +BUILTIN(__builtin_isgreaterequal, "i.", "nc") +BUILTIN(__builtin_isless , "i.", "nc") +BUILTIN(__builtin_islessequal , "i.", "nc") +BUILTIN(__builtin_islessgreater , "i.", "nc") +BUILTIN(__builtin_isunordered , "i.", "nc") + // Builtins for arithmetic. BUILTIN(__builtin_clz , "iUi" , "nc") BUILTIN(__builtin_clzl , "iULi" , "nc") From sabre at nondot.org Thu Dec 13 01:47:55 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 07:47:55 -0000 Subject: [cfe-commits] r44996 - /cfe/trunk/CodeGen/CGBuiltin.cpp Message-ID: <200712130747.lBD7ltcZ028172@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 01:47:54 2007 New Revision: 44996 URL: http://llvm.org/viewvc/llvm-project?rev=44996&view=rev Log: minor cleanups Modified: cfe/trunk/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGBuiltin.cpp?rev=44996&r1=44995&r2=44996&view=diff ============================================================================== --- cfe/trunk/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/CodeGen/CGBuiltin.cpp Thu Dec 13 01:47:54 2007 @@ -127,18 +127,14 @@ } case Builtin::BI__builtin_classify_type: { APSInt Result(32); - if (!E->isBuiltinClassifyType(Result)) assert(0 && "Expr not __builtin_classify_type!"); - return RValue::get(ConstantInt::get(Result)); } case Builtin::BI__builtin_constant_p: { APSInt Result(32); - // FIXME: Analyze the parameter and check if it is a constant. Result = 0; - return RValue::get(ConstantInt::get(Result)); } case Builtin::BI__builtin_abs: { From isanbard at gmail.com Thu Dec 13 03:57:43 2007 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 13 Dec 2007 09:57:43 -0000 Subject: [cfe-commits] r44998 - /cfe/trunk/www/get_involved.html Message-ID: <200712130957.lBD9vlqn013649@zion.cs.uiuc.edu> Author: void Date: Thu Dec 13 03:57:40 2007 New Revision: 44998 URL: http://llvm.org/viewvc/llvm-project?rev=44998&view=rev Log: Grammar fix: correct ' usage. Modified: cfe/trunk/www/get_involved.html Modified: cfe/trunk/www/get_involved.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_involved.html?rev=44998&r1=44997&r2=44998&view=diff ============================================================================== --- cfe/trunk/www/get_involved.html (original) +++ cfe/trunk/www/get_involved.html Thu Dec 13 03:57:40 2007 @@ -82,7 +82,7 @@
  • Continue work on C++ support: Implementing all of C++ is a very big job, but there are lots of little things that can be done. Right now we support some small things like references and bool. We also support parsing of -namespace's, but don't build ASTs for it. It would be straight-forward to +namespaces, but don't build ASTs for it. It would be straight-forward to implement support for representing namespaces, then add support for things like foo::bar::baz. Likewise, lots of other little pieces can be picked off and implemented.
  • From kremenek at apple.com Thu Dec 13 10:41:02 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 16:41:02 -0000 Subject: [cfe-commits] r45000 - /cfe/trunk/www/get_involved.html Message-ID: <200712131641.lBDGf2M0009062@zion.cs.uiuc.edu> Author: kremenek Date: Thu Dec 13 10:41:01 2007 New Revision: 45000 URL: http://llvm.org/viewvc/llvm-project?rev=45000&view=rev Log: Minor spelling; punctuation correction. Modified: cfe/trunk/www/get_involved.html Modified: cfe/trunk/www/get_involved.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_involved.html?rev=45000&r1=44999&r2=45000&view=diff ============================================================================== --- cfe/trunk/www/get_involved.html (original) +++ cfe/trunk/www/get_involved.html Thu Dec 13 10:41:01 2007 @@ -114,7 +114,7 @@

    If you hit a bug with clang, it is very useful for us if you reduce the code that demonstrates the problem down to something small. There are many ways to -do this, ask on cfe-dev for advise.

    +do this; ask on cfe-dev for advice.

    From fjahanian at apple.com Thu Dec 13 10:59:46 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Thu, 13 Dec 2007 08:59:46 -0800 Subject: [cfe-commits] r44025 - in /cfe/trunk: Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaExpr.cpp include/clang/Parse/Action.h In-Reply-To: <2176E1BC-CF7D-42C0-A8F5-F325A797CF6C@apple.com> References: <200711122013.lACKDSSE018960@zion.cs.uiuc.edu> <2176E1BC-CF7D-42C0-A8F5-F325A797CF6C@apple.com> Message-ID: On Dec 12, 2007, at 6:07 PM, Chris Lattner wrote: > On Nov 12, 2007, at 12:13 PM, Fariborz Jahanian wrote: >> Author: fjahanian >> Date: Mon Nov 12 14:13:27 2007 >> New Revision: 44025 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=44025&view=rev >> Log: >> 'super' nailed. > > Hi Fariborz, One thing: > >> +++ cfe/trunk/Sema/SemaExpr.cpp Mon Nov 12 14:13:27 2007 >> @@ -2060,13 +2060,34 @@ >> + ObjcInterfaceDecl* ClassDecl = 0; >> + if (!strcmp(receiverName->getName(), "super") && CurMethodDecl) { >> + ClassDecl = CurMethodDecl->getClassInterface()->getSuperClass(); >> + if (CurMethodDecl->isInstance()) { >> + IdentifierInfo &II = Context.Idents.get("self"); >> + ExprResult ReceiverExpr = ActOnIdentifierExpr(S, lbrac, II, >> + false); >> + QualType superTy = Context.getObjcInterfaceType(ClassDecl); >> + superTy = Context.getPointerType(superTy); >> + ReceiverExpr = ActOnCastExpr(SourceLocation(), >> superTy.getAsOpaquePtr(), >> + SourceLocation(), >> ReceiverExpr.Val); >> + >> + return ActOnInstanceMessage(ReceiverExpr.Val, Sel, lbrac, >> rbrac, >> + Args); > > This code appears to be synthesizing a definition of super on the > fly. This seems like exactly the same issue as self, etc. > Shouldn't it be handled the same way? Correct. This is related issue. - Fariborz > > > -Chris From sabre at nondot.org Thu Dec 13 11:25:36 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 17:25:36 -0000 Subject: [cfe-commits] r45001 - /cfe/trunk/www/get_involved.html Message-ID: <200712131725.lBDHPaee013353@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 11:25:36 2007 New Revision: 45001 URL: http://llvm.org/viewvc/llvm-project?rev=45001&view=rev Log: debug info too. Modified: cfe/trunk/www/get_involved.html Modified: cfe/trunk/www/get_involved.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_involved.html?rev=45001&r1=45000&r2=45001&view=diff ============================================================================== --- cfe/trunk/www/get_involved.html (original) +++ cfe/trunk/www/get_involved.html Thu Dec 13 11:25:36 2007 @@ -74,11 +74,16 @@ compile it. If not, please let us know. Once it compiles it should run. If not, that's a bug :) -
  • Working on code generation for Objective C: -emit-llvm support for +
  • Work on code generation for Objective C: -emit-llvm support for Objective C is basically non-existant at the time of this writing, this is a nice open project that can be tackled incrementally (one language feature at a time).
  • +
  • Debug Info Generation: -emit-llvm doesn't currently support emission +of LLVM debug info +(which the code generator turns into DWARF). Adding this should be +straight-forward if you follow the example of what llvm-gcc generates.
  • +
  • Continue work on C++ support: Implementing all of C++ is a very big job, but there are lots of little things that can be done. Right now we support some small things like references and bool. We also support parsing of From sabre at nondot.org Thu Dec 13 11:27:09 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 17:27:09 -0000 Subject: [cfe-commits] r45002 - /cfe/trunk/www/get_involved.html Message-ID: <200712131727.lBDHR9u5013442@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 11:27:09 2007 New Revision: 45002 URL: http://llvm.org/viewvc/llvm-project?rev=45002&view=rev Log: typo Modified: cfe/trunk/www/get_involved.html Modified: cfe/trunk/www/get_involved.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_involved.html?rev=45002&r1=45001&r2=45002&view=diff ============================================================================== --- cfe/trunk/www/get_involved.html (original) +++ cfe/trunk/www/get_involved.html Thu Dec 13 11:27:09 2007 @@ -75,7 +75,7 @@ not, that's a bug :)
  • Work on code generation for Objective C: -emit-llvm support for -Objective C is basically non-existant at the time of this writing, this is a +Objective C is basically nonexistent at the time of this writing, this is a nice open project that can be tackled incrementally (one language feature at a time).
  • From fjahanian at apple.com Thu Dec 13 11:41:58 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Thu, 13 Dec 2007 09:41:58 -0800 Subject: [cfe-commits] r44028 - in /cfe/trunk: AST/StmtPrinter.cpp Sema/SemaExpr.cpp include/clang/AST/Expr.h test/Sema/static-ivar-ref-1.m In-Reply-To: References: <200711122229.lACMTTI9025355@zion.cs.uiuc.edu> Message-ID: On Dec 12, 2007, at 8:44 PM, Chris Lattner wrote: > > Hi Fariborz, > >> +++ cfe/trunk/Sema/SemaExpr.cpp Mon Nov 12 16:29:28 2007 >> @@ -519,9 +519,20 @@ >> if (ret.isNull()) >> return true; >> return new OCUVectorElementExpr(ret, BaseExpr, Member, MemberLoc); >> + } else if (BaseType->isObjcInterfaceType()) { >> + ObjcInterfaceDecl *IFace; >> + if (isa(BaseType.getCanonicalType())) >> + IFace = dyn_cast(BaseType)->getDecl(); >> + else >> + IFace = dyn_cast(BaseType) >> + ->getInterfaceType()->getDecl(); > > Code like this could be simplified if ObjcQualifiedInterfaceType > inherited from ObjcInterfaceType. Would it make sense to do this? > Then the code above would just be: It makes sense. I will change it later today. - Fariborz From sabre at nondot.org Thu Dec 13 11:34:31 2007 From: sabre at nondot.org (Chris Lattner) Date: Thu, 13 Dec 2007 17:34:31 -0000 Subject: [cfe-commits] r45003 - /cfe/trunk/Driver/ASTConsumers.cpp Message-ID: <200712131734.lBDHYVwg013725@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 13 11:34:31 2007 New Revision: 45003 URL: http://llvm.org/viewvc/llvm-project?rev=45003&view=rev Log: Set target data layout info in module. Modified: cfe/trunk/Driver/ASTConsumers.cpp Modified: cfe/trunk/Driver/ASTConsumers.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=45003&r1=45002&r2=45003&view=diff ============================================================================== --- cfe/trunk/Driver/ASTConsumers.cpp (original) +++ cfe/trunk/Driver/ASTConsumers.cpp Thu Dec 13 11:34:31 2007 @@ -570,6 +570,7 @@ Ctx = &Context; M = new llvm::Module("foo"); M->setTargetTriple(Ctx->Target.getTargetTriple()); + M->setDataLayout(Ctx->Target.getTargetDescription()); TD = new llvm::TargetData(Ctx->Target.getTargetDescription()); Builder = CodeGen::Init(Context, Features, *M, *TD, Diags); } From kremenek at apple.com Thu Dec 13 11:50:11 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 17:50:11 -0000 Subject: [cfe-commits] r45004 - in /cfe/trunk/Driver: ASTConsumers.cpp clang.cpp Message-ID: <200712131750.lBDHoBSA014273@zion.cs.uiuc.edu> Author: kremenek Date: Thu Dec 13 11:50:11 2007 New Revision: 45004 URL: http://llvm.org/viewvc/llvm-project?rev=45004&view=rev Log: Changed -serialize-ast to not create a temporary directory, but instead create a .ast file in the current working directory. This mirrors the behavior of the -c option for gcc. Later we should add the ability to write the serialized file anywhere. Modified: cfe/trunk/Driver/ASTConsumers.cpp cfe/trunk/Driver/clang.cpp Modified: cfe/trunk/Driver/ASTConsumers.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=45004&r1=45003&r2=45004&view=diff ============================================================================== --- cfe/trunk/Driver/ASTConsumers.cpp (original) +++ cfe/trunk/Driver/ASTConsumers.cpp Thu Dec 13 11:50:11 2007 @@ -552,7 +552,6 @@ #include "llvm/Module.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" -#include namespace { class LLVMEmitter : public ASTConsumer { @@ -596,7 +595,7 @@ CodeGen::Terminate(Builder); // Print the generated code. - M->print(std::cout); + M->print(llvm::cout.stream()); delete M; } }; Modified: cfe/trunk/Driver/clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=45004&r1=45003&r2=45004&view=diff ============================================================================== --- cfe/trunk/Driver/clang.cpp (original) +++ cfe/trunk/Driver/clang.cpp Thu Dec 13 11:50:11 2007 @@ -856,15 +856,16 @@ case SerializeAST: { // FIXME: Allow user to tailor where the file is written. - llvm::sys::Path FName = llvm::sys::Path::GetTemporaryDirectory(NULL); - FName.appendComponent((InFile + ".ast").c_str()); + // FIXME: This is a hack: "/" separator not portable. + std::string::size_type idx = InFile.rfind("/"); - if (FName.makeUnique(true,NULL)) { - fprintf (stderr, "error: cannot create serialized file: '%s'\n", - FName.c_str()); - + if (idx != std::string::npos && idx == InFile.size()-1) return NULL; - } + + std::string TargetPrefix( idx == std::string::npos ? + InFile : InFile.substr(idx+1)); + + llvm::sys::Path FName = llvm::sys::Path((TargetPrefix + ".ast").c_str()); return CreateASTSerializer(FName, Diag, LangOpts); } From kremenek at apple.com Thu Dec 13 11:54:02 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 17:54:02 -0000 Subject: [cfe-commits] r45005 - in /cfe/trunk/Driver: TranslationUnit.cpp TranslationUnit.h Message-ID: <200712131754.lBDHs2Ik014459@zion.cs.uiuc.edu> Author: kremenek Date: Thu Dec 13 11:54:02 2007 New Revision: 45005 URL: http://llvm.org/viewvc/llvm-project?rev=45005&view=rev Log: Changed set of top-level decls from a list to a vector. Modified: cfe/trunk/Driver/TranslationUnit.cpp cfe/trunk/Driver/TranslationUnit.h Modified: cfe/trunk/Driver/TranslationUnit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TranslationUnit.cpp?rev=45005&r1=45004&r2=45005&view=diff ============================================================================== --- cfe/trunk/Driver/TranslationUnit.cpp (original) +++ cfe/trunk/Driver/TranslationUnit.cpp Thu Dec 13 11:54:02 2007 @@ -1,4 +1,4 @@ -//===--- TranslationUnit.cpp - Abstraccction for Translation Units --------===// +//===--- TranslationUnit.cpp - Abstraction for Translation Units ----------===// // // The LLVM Compiler Infrastructure // Modified: cfe/trunk/Driver/TranslationUnit.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/TranslationUnit.h?rev=45005&r1=45004&r2=45005&view=diff ============================================================================== --- cfe/trunk/Driver/TranslationUnit.h (original) +++ cfe/trunk/Driver/TranslationUnit.h Thu Dec 13 11:54:02 2007 @@ -16,7 +16,7 @@ #include "clang/Basic/LangOptions.h" #include "llvm/Bitcode/SerializationFwd.h" #include "llvm/System/Path.h" -#include +#include namespace clang { @@ -31,7 +31,7 @@ class TranslationUnit { LangOptions LangOpts; ASTContext* Context; - std::list TopLevelDecls; + std::vector TopLevelDecls; explicit TranslationUnit() : Context(NULL) {} @@ -68,11 +68,11 @@ TopLevelDecls.push_back(d); } - typedef std::list::iterator iterator; + typedef std::vector::iterator iterator; iterator begin() { return TopLevelDecls.begin(); } iterator end() { return TopLevelDecls.end(); } - typedef std::list::const_iterator const_iterator; + typedef std::vector::const_iterator const_iterator; const_iterator begin() const { return TopLevelDecls.begin(); } const_iterator end() const { return TopLevelDecls.end(); } }; From kremenek at apple.com Thu Dec 13 12:11:11 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 18:11:11 -0000 Subject: [cfe-commits] r45006 - /cfe/trunk/Driver/clang.cpp Message-ID: <200712131811.lBDIBBkE015184@zion.cs.uiuc.edu> Author: kremenek Date: Thu Dec 13 12:11:11 2007 New Revision: 45006 URL: http://llvm.org/viewvc/llvm-project?rev=45006&view=rev Log: Add check in the driver to see if a serialized AST file has been successfully deserialized. Modified: cfe/trunk/Driver/clang.cpp Modified: cfe/trunk/Driver/clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/clang.cpp?rev=45006&r1=45005&r2=45006&view=diff ============================================================================== --- cfe/trunk/Driver/clang.cpp (original) +++ cfe/trunk/Driver/clang.cpp Thu Dec 13 12:11:11 2007 @@ -984,7 +984,14 @@ exit (1); } - TranslationUnit* TU = TranslationUnit::ReadBitcodeFile(Filename,FileMgr); + TranslationUnit* TU = TranslationUnit::ReadBitcodeFile(Filename,FileMgr); + + if (!TU) { + fprintf(stderr, "error: file '%s' could not be deserialized\n", + InFile.c_str()); + exit (1); + } + ASTConsumer* Consumer = CreateASTConsumer(InFile,Diag, FileMgr,TU->getLangOpts()); From kremenek at apple.com Thu Dec 13 12:12:10 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 18:12:10 -0000 Subject: [cfe-commits] r45007 - /cfe/trunk/Basic/SourceManager.cpp Message-ID: <200712131812.lBDICA7I015240@zion.cs.uiuc.edu> Author: kremenek Date: Thu Dec 13 12:12:10 2007 New Revision: 45007 URL: http://llvm.org/viewvc/llvm-project?rev=45007&view=rev Log: Add hack to SourceManager to support missing source files during deserialization. Eventually this should be replaced with a lazy-reading mechanism that only reads source files when they are needed by clients. Modified: cfe/trunk/Basic/SourceManager.cpp Modified: cfe/trunk/Basic/SourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Basic/SourceManager.cpp?rev=45007&r1=45006&r2=45007&view=diff ============================================================================== --- cfe/trunk/Basic/SourceManager.cpp (original) +++ cfe/trunk/Basic/SourceManager.cpp Thu Dec 13 12:12:10 2007 @@ -441,10 +441,14 @@ const char* start = &Buf[0]; const FileEntry* E = FMgr->getFile(start,start+Buf.size()); - assert (E && "Not yet supported: missing files."); - - // Get the ContextCache object and register it with the deserializer. - D.RegisterPtr(PtrID,SMgr.getContentCache(E)); + // FIXME: Ideally we want a lazy materialization of the ContentCache + // anyway, because we don't want to read in source files unless this + // is absolutely needed. + if (!E) + D.RegisterPtr(PtrID,NULL); + else + // Get the ContextCache object and register it with the deserializer. + D.RegisterPtr(PtrID,SMgr.getContentCache(E)); } else { // Register the ContextCache object with the deserializer. From snaroff at apple.com Thu Dec 13 12:18:56 2007 From: snaroff at apple.com (Steve Naroff) Date: Thu, 13 Dec 2007 18:18:56 -0000 Subject: [cfe-commits] r45008 - /cfe/trunk/Sema/SemaDecl.cpp Message-ID: <200712131818.lBDIIv9F015495@zion.cs.uiuc.edu> Author: snaroff Date: Thu Dec 13 12:18:56 2007 New Revision: 45008 URL: http://llvm.org/viewvc/llvm-project?rev=45008&view=rev Log: Sema::ActOnFinishFunctionBody(): Since we no longer synthesize a FunctionDecl for each method, remove the unconditional initialization to 0 and corresponding comment. Modified: cfe/trunk/Sema/SemaDecl.cpp Modified: cfe/trunk/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=45008&r1=45007&r2=45008&view=diff ============================================================================== --- cfe/trunk/Sema/SemaDecl.cpp (original) +++ cfe/trunk/Sema/SemaDecl.cpp Thu Dec 13 12:18:56 2007 @@ -1016,13 +1016,11 @@ if (FunctionDecl *FD = dyn_cast(dcl)) { FD->setBody((Stmt*)Body); assert(FD == CurFunctionDecl && "Function parsing confused"); + CurFunctionDecl = 0; } else if (ObjcMethodDecl *MD = dyn_cast(dcl)) { MD->setBody((Stmt*)Body); CurMethodDecl = 0; - } - // This is unconditional, since methods have a corresponding function decl. - CurFunctionDecl = 0; - + } // Verify and clean out per-function state. // Check goto/label use. From fjahanian at apple.com Thu Dec 13 14:47:43 2007 From: fjahanian at apple.com (Fariborz Jahanian) Date: Thu, 13 Dec 2007 20:47:43 -0000 Subject: [cfe-commits] r45014 - in /cfe/trunk: AST/ASTContext.cpp AST/Type.cpp Sema/SemaExpr.cpp include/clang/AST/Type.h Message-ID: <200712132047.lBDKlhZs023916@zion.cs.uiuc.edu> Author: fjahanian Date: Thu Dec 13 14:47:42 2007 New Revision: 45014 URL: http://llvm.org/viewvc/llvm-project?rev=45014&view=rev Log: Patch to make ObjcQualifiedInterfaceType inherit ObjcInterfaceType Modified: cfe/trunk/AST/ASTContext.cpp cfe/trunk/AST/Type.cpp cfe/trunk/Sema/SemaExpr.cpp cfe/trunk/include/clang/AST/Type.h Modified: cfe/trunk/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/ASTContext.cpp?rev=45014&r1=45013&r2=45014&view=diff ============================================================================== --- cfe/trunk/AST/ASTContext.cpp (original) +++ cfe/trunk/AST/ASTContext.cpp Thu Dec 13 14:47:42 2007 @@ -687,7 +687,7 @@ QualType ASTContext::getObjcInterfaceType(ObjcInterfaceDecl *Decl) { if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0); - Decl->TypeForDecl = new ObjcInterfaceType(Decl); + Decl->TypeForDecl = new ObjcInterfaceType(Type::ObjcInterface, Decl); Types.push_back(Decl->TypeForDecl); return QualType(Decl->TypeForDecl, 0); } @@ -697,11 +697,8 @@ /// the conforming protocol list. QualType ASTContext::getObjcQualifiedInterfaceType(ObjcInterfaceDecl *Decl, ObjcProtocolDecl **Protocols, unsigned NumProtocols) { - ObjcInterfaceType *IType = - cast(getObjcInterfaceType(Decl)); - llvm::FoldingSetNodeID ID; - ObjcQualifiedInterfaceType::Profile(ID, IType, Protocols, NumProtocols); + ObjcQualifiedInterfaceType::Profile(ID, Protocols, NumProtocols); void *InsertPos = 0; if (ObjcQualifiedInterfaceType *QT = @@ -710,7 +707,7 @@ // No Match; ObjcQualifiedInterfaceType *QType = - new ObjcQualifiedInterfaceType(IType, Protocols, NumProtocols); + new ObjcQualifiedInterfaceType(Decl, Protocols, NumProtocols); Types.push_back(QType); ObjcQualifiedInterfaceTypes.InsertNode(QType, InsertPos); return QualType(QType, 0); @@ -1204,8 +1201,8 @@ ObjcQualifiedInterfaceType *rhsQI = dyn_cast(rhs.getCanonicalType().getTypePtr()); assert(rhsQI && "QualifiedInterfaceTypesAreCompatible - bad rhs type"); - if (!interfaceTypesAreCompatible(QualType(lhsQI->getInterfaceType(), 0), - QualType(rhsQI->getInterfaceType(), 0))) + if (!interfaceTypesAreCompatible(getObjcInterfaceType(lhsQI->getDecl()), + getObjcInterfaceType(rhsQI->getDecl()))) return false; /* All protocols in lhs must have a presense in rhs. */ for (unsigned i =0; i < lhsQI->getNumProtocols(); i++) { Modified: cfe/trunk/AST/Type.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Type.cpp?rev=45014&r1=45013&r2=45014&view=diff ============================================================================== --- cfe/trunk/AST/Type.cpp (original) +++ cfe/trunk/AST/Type.cpp Thu Dec 13 14:47:42 2007 @@ -529,16 +529,14 @@ } void ObjcQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID, - ObjcInterfaceType *interfaceType, ObjcProtocolDecl **protocols, unsigned NumProtocols) { - ID.AddPointer(interfaceType); for (unsigned i = 0; i != NumProtocols; i++) ID.AddPointer(protocols[i]); } void ObjcQualifiedInterfaceType::Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, getInterfaceType(), &Protocols[0], getNumProtocols()); + Profile(ID, &Protocols[0], getNumProtocols()); } /// LookThroughTypedefs - Return the ultimate type this typedef corresponds to @@ -770,7 +768,7 @@ std::string &InnerString) const { if (!InnerString.empty()) // Prefix the basic type, e.g. 'typedefname X'. InnerString = ' ' + InnerString; - std::string ObjcQIString = getInterfaceType()->getDecl()->getName(); + std::string ObjcQIString = getDecl()->getName(); ObjcQIString += '<'; int num = getNumProtocols(); for (int i = 0; i < num; i++) { Modified: cfe/trunk/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=45014&r1=45013&r2=45014&view=diff ============================================================================== --- cfe/trunk/Sema/SemaExpr.cpp (original) +++ cfe/trunk/Sema/SemaExpr.cpp Thu Dec 13 14:47:42 2007 @@ -540,8 +540,7 @@ if (isa(BaseType.getCanonicalType())) IFace = dyn_cast(BaseType)->getDecl(); else - IFace = dyn_cast(BaseType) - ->getInterfaceType()->getDecl(); + IFace = dyn_cast(BaseType)->getDecl(); ObjcInterfaceDecl *clsDeclared; if (ObjcIvarDecl *IV = IFace->lookupInstanceVariable(&Member, clsDeclared)) return new ObjCIvarRefExpr(IV, IV->getType(), MemberLoc, BaseExpr, @@ -2300,9 +2299,7 @@ ObjcInterfaceDecl* ClassDecl; if (ObjcQualifiedInterfaceType *QIT = dyn_cast(receiverType)) { - ObjcInterfaceType * OITypePtr = QIT->getInterfaceType(); - - ClassDecl = OITypePtr->getDecl(); + ClassDecl = QIT->getDecl(); Method = ClassDecl->lookupInstanceMethod(Sel); if (!Method) { // search protocols Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=45014&r1=45013&r2=45014&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Thu Dec 13 14:47:42 2007 @@ -899,9 +899,9 @@ class ObjcInterfaceType : public Type { ObjcInterfaceDecl *Decl; - - ObjcInterfaceType(ObjcInterfaceDecl *D) : - Type(ObjcInterface, QualType()), Decl(D) { } +protected: + ObjcInterfaceType(TypeClass tc, ObjcInterfaceDecl *D) : + Type(tc, QualType()), Decl(D) { } friend class ASTContext; // ASTContext creates these. public: @@ -919,23 +919,20 @@ /// conforming to a list of protocols; such as, INTF. /// Duplicate protocols are removed and protocol list is canonicalized to be in /// alphabetical order. -class ObjcQualifiedInterfaceType : public Type, public llvm::FoldingSetNode { - // Interface type for this protocol conforming object type - ObjcInterfaceType *InterfaceType; - +class ObjcQualifiedInterfaceType : public ObjcInterfaceType, + public llvm::FoldingSetNode { + // List of protocols for this protocol conforming object type // List is sorted on protocol name. No protocol is enterred more than once. llvm::SmallVector Protocols; - ObjcQualifiedInterfaceType(ObjcInterfaceType *T, + ObjcQualifiedInterfaceType(ObjcInterfaceDecl *D, ObjcProtocolDecl **Protos, unsigned NumP) : - Type(ObjcQualifiedInterface, QualType()), InterfaceType(T), + ObjcInterfaceType(ObjcQualifiedInterface, D), Protocols(Protos, Protos+NumP) { } friend class ASTContext; // ASTContext creates these. public: - ObjcInterfaceType *getInterfaceType() const { return InterfaceType; } - ObjcProtocolDecl *getProtocols(unsigned i) const { return Protocols[i]; } @@ -947,7 +944,6 @@ void Profile(llvm::FoldingSetNodeID &ID); static void Profile(llvm::FoldingSetNodeID &ID, - ObjcInterfaceType *interfaceType, ObjcProtocolDecl **protocols, unsigned NumProtocols); static bool classof(const Type *T) { From kremenek at apple.com Thu Dec 13 16:44:19 2007 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 13 Dec 2007 22:44:19 -0000 Subject: [cfe-commits] r45015 - /cfe/trunk/AST/CFG.cpp Message-ID: <200712132244.lBDMiJA0029844@zion.cs.uiuc.edu> Author: kremenek Date: Thu Dec 13 16:44:18 2007 New Revision: 45015 URL: http://llvm.org/viewvc/llvm-project?rev=45015&view=rev Log: CFG bug fix: for sizeof(expressions), don't expand the control-flow of "expressions", since they are not really evaluated. Modified: cfe/trunk/AST/CFG.cpp Modified: cfe/trunk/AST/CFG.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/CFG.cpp?rev=45015&r1=45014&r2=45015&view=diff ============================================================================== --- cfe/trunk/AST/CFG.cpp (original) +++ cfe/trunk/AST/CFG.cpp Thu Dec 13 16:44:18 2007 @@ -225,8 +225,7 @@ // of the ternary expression. CFGBlock* ConfluenceBlock = (Block) ? Block : createBlock(); ConfluenceBlock->appendStmt(C); - FinishBlock(ConfluenceBlock); - + FinishBlock(ConfluenceBlock); // Create a block for the LHS expression if there is an LHS expression. // A GCC extension allows LHS to be NULL, causing the condition to @@ -317,6 +316,20 @@ case Stmt::StmtExprClass: return WalkAST_VisitStmtExpr(cast(S)); + case Stmt::UnaryOperatorClass: { + UnaryOperator* U = cast(S); + + // sizeof(expressions). For such expressions, + // the subexpression is not really evaluated, so + // we don't care about control-flow within the sizeof. + if (U->getOpcode() == UnaryOperator::SizeOf) { + Block->appendStmt(S); + return Block; + } + + break; + } + case Stmt::BinaryOperatorClass: { BinaryOperator* B = cast(S); @@ -345,14 +358,16 @@ addStmt(B->getRHS()); return addStmt(B->getLHS()); } - - // Fall through to the default case. + + break; } default: - if (AlwaysAddStmt) Block->appendStmt(S); - return WalkAST_VisitChildren(S); + break; }; + + if (AlwaysAddStmt) Block->appendStmt(S); + return WalkAST_VisitChildren(S); } /// WalkAST_VisitDeclSubExprs - Utility method to handle Decls contained in From mrs at apple.com Thu Dec 13 17:37:10 2007 From: mrs at apple.com (Mike Stump) Date: Thu, 13 Dec 2007 15:37:10 -0800 Subject: [cfe-commits] r45015 - /cfe/trunk/AST/CFG.cpp In-Reply-To: <200712132244.lBDMiJA0029844@zion.cs.uiuc.edu> References: <200712132244.lBDMiJA0029844@zion.cs.uiuc.edu> Message-ID: <7B124881-804B-4881-826F-9E2E97CBCD89@apple.com> On Dec 13, 2007, at 2:44 PM, Ted Kremenek wrote: > Author: kremenek > Date: Thu Dec 13 16:44:18 2007 > New Revision: 45015 > > URL: http://llvm.org/viewvc/llvm-project?rev=45015&view=rev > Log: > CFG bug fix: for sizeof(expressions), don't expand the control-flow > of "expressions", since they are not really evaluated. 6.5.3.4 The sizeof operator Constraints [#1] The sizeof operator shall not be applied to an expression that has function type or an incomplete type, to the parenthesized name of such a type, or to an lvalue that designates a bit-field object. Semantics [#2] The sizeof operator yields the size (in bytes) of its operand, which may be an expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is an integer. If the type of the operand is a variable length array type, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant. notice the operand is evaluated part... :-) From sanxiyn at gmail.com Thu Dec 13 19:09:11 2007 From: sanxiyn at gmail.com (Seo Sanghyeon) Date: Fri, 14 Dec 2007 01:09:11 -0000 Subject: [cfe-commits] r45020 - in /cfe/trunk: CodeGen/CGExprAgg.cpp test/CodeGen/struct.c Message-ID: <200712140109.lBE19B5L003817@zion.cs.uiuc.edu> Author: sanxiyn Date: Thu Dec 13 19:09:11 2007 New Revision: 45020 URL: http://llvm.org/viewvc/llvm-project?rev=45020&view=rev Log: Implement dereference operator in aggregate expression Modified: cfe/trunk/CodeGen/CGExprAgg.cpp cfe/trunk/test/CodeGen/struct.c Modified: cfe/trunk/CodeGen/CGExprAgg.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprAgg.cpp?rev=45020&r1=45019&r2=45020&view=diff ============================================================================== --- cfe/trunk/CodeGen/CGExprAgg.cpp (original) +++ cfe/trunk/CodeGen/CGExprAgg.cpp Thu Dec 13 19:09:11 2007 @@ -61,6 +61,7 @@ // l-values. void VisitDeclRefExpr(DeclRefExpr *DRE) { return EmitAggLoadOfLValue(DRE); } void VisitMemberExpr(MemberExpr *ME) { return EmitAggLoadOfLValue(ME); } + void VisitUnaryDeref(UnaryOperator *E) { return EmitAggLoadOfLValue(E); } // case Expr::ArraySubscriptExprClass: Modified: cfe/trunk/test/CodeGen/struct.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/struct.c?rev=45020&r1=45019&r2=45020&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/struct.c (original) +++ cfe/trunk/test/CodeGen/struct.c Thu Dec 13 19:09:11 2007 @@ -89,6 +89,10 @@ range r = p.range1; } +void f9(range *p) +{ + range r = *p; +} /* _Bool types */ From sanxiyn at gmail.com Thu Dec 13 20:04:12 2007 From: sanxiyn at gmail.com (Seo Sanghyeon) Date: Fri, 14 Dec 2007 02:04:12 -0000 Subject: [cfe-commits] r45023 - in /cfe/trunk: CodeGen/CGExprAgg.cpp test/CodeGen/struct.c Message-ID: <200712140204.lBE24COi006452@zion.cs.uiuc.edu> Author: sanxiyn Date: Thu Dec 13 20:04:12 2007 New Revision: 45023 URL: http://llvm.org/viewvc/llvm-project?rev=45023&view=rev Log: Array subscription in aggregate expression Modified: cfe/trunk/CodeGen/CGExprAgg.cpp cfe/trunk/test/CodeGen/struct.c Modified: cfe/trunk/CodeGen/CGExprAgg.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprAgg.cpp?rev=45023&r1=45022&r2=45023&view=diff ============================================================================== --- cfe/trunk/CodeGen/CGExprAgg.cpp (original) +++ cfe/trunk/CodeGen/CGExprAgg.cpp Thu Dec 13 20:04:12 2007 @@ -59,11 +59,13 @@ void VisitParenExpr(ParenExpr *PE) { Visit(PE->getSubExpr()); } // l-values. - void VisitDeclRefExpr(DeclRefExpr *DRE) { return EmitAggLoadOfLValue(DRE); } - void VisitMemberExpr(MemberExpr *ME) { return EmitAggLoadOfLValue(ME); } - void VisitUnaryDeref(UnaryOperator *E) { return EmitAggLoadOfLValue(E); } - - // case Expr::ArraySubscriptExprClass: + void VisitDeclRefExpr(DeclRefExpr *DRE) { EmitAggLoadOfLValue(DRE); } + void VisitMemberExpr(MemberExpr *ME) { EmitAggLoadOfLValue(ME); } + void VisitUnaryDeref(UnaryOperator *E) { EmitAggLoadOfLValue(E); } + + void VisitArraySubscriptExpr(ArraySubscriptExpr *E) { + EmitAggLoadOfLValue(E); + } // Operators. // case Expr::UnaryOperatorClass: Modified: cfe/trunk/test/CodeGen/struct.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/struct.c?rev=45023&r1=45022&r2=45023&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/struct.c (original) +++ cfe/trunk/test/CodeGen/struct.c Thu Dec 13 20:04:12 2007 @@ -94,6 +94,11 @@ range r = *p; } +void f10(range *p) +{ + range r = p[0]; +} + /* _Bool types */ struct _w From ar18 at comcast.net Thu Dec 13 23:47:51 2007 From: ar18 at comcast.net (Kevin) Date: Fri, 14 Dec 2007 05:47:51 -0000 Subject: [cfe-commits] r45025 - in /cfe/trunk/www: clang_video-05-25-2007.html clang_video-07-25-2007.html comparison.html index.html menu.css menu.html.incl Message-ID: <200712140547.lBE5lpGk022223@zion.cs.uiuc.edu> Author: kevin Date: Thu Dec 13 23:47:49 2007 New Revision: 45025 URL: http://llvm.org/viewvc/llvm-project?rev=45025&view=rev Log: IE Menu Problem... Originally, I included CSS hacks for IE. However, my comments before the doctype was the reason IE was running in non-strict mode. I did not know this. When Chris removed the comments, IE correctly went into strict mode and my IE hacks were no longer needed (the hacks were getting in the way now). solution: *) Make sure doctype is first on all files *) removed all IE hacks from menu.css (since the doctype issue fixes IE) Modified: cfe/trunk/www/clang_video-05-25-2007.html cfe/trunk/www/clang_video-07-25-2007.html cfe/trunk/www/comparison.html cfe/trunk/www/index.html cfe/trunk/www/menu.css cfe/trunk/www/menu.html.incl Modified: cfe/trunk/www/clang_video-05-25-2007.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/clang_video-05-25-2007.html?rev=45025&r1=45024&r2=45025&view=diff ============================================================================== --- cfe/trunk/www/clang_video-05-25-2007.html (original) +++ cfe/trunk/www/clang_video-05-25-2007.html Thu Dec 13 23:47:49 2007 @@ -1,5 +1,5 @@ - + Modified: cfe/trunk/www/clang_video-07-25-2007.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/clang_video-07-25-2007.html?rev=45025&r1=45024&r2=45025&view=diff ============================================================================== --- cfe/trunk/www/clang_video-07-25-2007.html (original) +++ cfe/trunk/www/clang_video-07-25-2007.html Thu Dec 13 23:47:49 2007 @@ -1,5 +1,5 @@ - + Modified: cfe/trunk/www/comparison.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=45025&r1=45024&r2=45025&view=diff ============================================================================== --- cfe/trunk/www/comparison.html (original) +++ cfe/trunk/www/comparison.html Thu Dec 13 23:47:49 2007 @@ -1,6 +1,6 @@ - + Modified: cfe/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/index.html?rev=45025&r1=45024&r2=45025&view=diff ============================================================================== --- cfe/trunk/www/index.html (original) +++ cfe/trunk/www/index.html Thu Dec 13 23:47:49 2007 @@ -1,6 +1,6 @@ - + Modified: cfe/trunk/www/menu.css URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/menu.css?rev=45025&r1=45024&r2=45025&view=diff ============================================================================== --- cfe/trunk/www/menu.css (original) +++ cfe/trunk/www/menu.css Thu Dec 13 23:47:49 2007 @@ -2,42 +2,34 @@ /* page layout */ /***************/ -/***IE***/ -#menu { - float:left; -} -#content { - float:left; - margin-left:1ex; -} -/***W3C***/ [id=menu] { position:fixed; } [id=content] { - /* ***** EDIT THIS VALUE IF CONTENT OVERLAPS MENU ***** */ - padding-left:16ex; + /* ***** EDIT THIS VALUE IF CONTENT OVERLAPS MENU ***** */ + padding-left:16ex; } /**************/ /* menu style */ -/**************/ - -#menu .submenu { - padding-top:1em; - display:block; -} +/**************/ + +#menu .submenu { + padding-top:1em; + display:block; +} #menu label { - display:block; - font-weight: bold; + display:block; + font-weight: bold; text-align: center; - background-color: rgb(192,192,192); + background-color: rgb(192,192,192); } #menu a { - display:block; + padding:0 .2em; + display:block; text-align: center; - background-color: rgb(235,235,235); + background-color: rgb(235,235,235); } #menu a:visited { color:rgb(100,50,100); Modified: cfe/trunk/www/menu.html.incl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/www/menu.html.incl?rev=45025&r1=45024&r2=45025&view=diff ============================================================================== --- cfe/trunk/www/menu.html.incl (original) +++ cfe/trunk/www/menu.html.incl Thu Dec 13 23:47:49 2007 @@ -10,7 +10,7 @@ Comparisons Get Started Get Involved - clang Internals + Clang Internals