Am Sa., 2. März 2019 um 11:15 Uhr schrieb Chris Lattner via llvm-dev <llvm-dev at lists.llvm.org>:> I’d be really opposed to flang reusing the Clang ASTs themselves. C++ is already a complicated language and mixing all of Fortran's concerns (including a completely different object model) will make both of them *worse* than having them stand alone IMO.Could there be a common base class for flang and clang AST nodes? That is, an abstract class that has children()/dump()/getSourceRange()? Michael
> On Mar 4, 2019, at 12:03 PM, Michael Kruse <llvmdev at meinersbur.de> wrote: > > Am Sa., 2. März 2019 um 11:15 Uhr schrieb Chris Lattner via llvm-dev > <llvm-dev at lists.llvm.org>: >> I’d be really opposed to flang reusing the Clang ASTs themselves. C++ is already a complicated language and mixing all of Fortran's concerns (including a completely different object model) will make both of them *worse* than having them stand alone IMO. > > Could there be a common base class for flang and clang AST nodes? That > is, an abstract class that has children()/dump()/getSourceRange()?What useful code (other than trivial dumpers) could work at that level of abstraction? -Chris
Am Di., 5. März 2019 um 11:57 Uhr schrieb Chris Lattner <clattner at nondot.org>:> > Could there be a common base class for flang and clang AST nodes? That > > is, an abstract class that has children()/dump()/getSourceRange()? > > What useful code (other than trivial dumpers) could work at that level of abstraction?Some tooling components are not dependent much on what semantics an AST node represents. Some ideas: * clang-query/ASTMatcher, especially those that check for the node type only. * clang-tidy: Just have a different set of checkers for C/C++/ObjC/Fortran; (As alternative to duplicating or templating code on Fortran/Clang AST types) * clang-diff * serialization/deserialization of ASTs * graphviz visualization Michael
On 05/03/2019 10:57, Chris Lattner via llvm-dev wrote:>> On Mar 4, 2019, at 12:03 PM, Michael Kruse<llvmdev at meinersbur.de> wrote: >> >> Am Sa., 2. März 2019 um 11:15 Uhr schrieb Chris Lattner via llvm-dev >> <llvm-dev at lists.llvm.org>: >>> I’d be really opposed to flang reusing the Clang ASTs themselves. C++ is already a complicated language and mixing all of Fortran's concerns (including a completely different object model) will make both of them*worse* than having them stand alone IMO. >> Could there be a common base class for flang and clang AST nodes? That >> is, an abstract class that has children()/dump()/getSourceRange()? > What useful code (other than trivial dumpers) could work at that level of abstraction?The main thing that springs to mind is a documentation generator. It needs to be able to find comments associated with some language construct, index language constructs, and produce cross references. You would still need to have Fortran-specific support, just as you'd need to understand that C++ and Objective-C have different notions of inheritance, but a lot of the core infrastructure could be shared if clang and f18 exposed compatible interfaces to the AST. David