P. Goldsborough “clang-useful: Building useful tools with LLVM and clang for fun and profit"

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone very happy to be here my name is Peter I'm actually really excited to be here at all because I was supposed to be here on Thursday like evening but I arrived last night at 8:00 so like I arrived in Denver on Thursday and then my bus got canceled due to a snowstorm because like you can't just come to Colorado and not have a snowstorm you plug up your trip it's like it's what you pay for in the flight and I'm also still waiting for the bear modeling experience but anyways there I slept in a train station which if you were planning to sleep on the train station I don't recommend it but yes then I took the train left this morning or last warning story and then like all the things happen like rocks on the on the railroad and we're the fifth flight in the Train so if someone has to like call an ambulance and I guess one of them lost one but yeah happy to be here okay so this talk is about clang and LVM the topic is very exciting really think it's important for everyone and to some extent I liken it to taking some of the power of the impotence compilers and giving it to the people to the mortal developers because as you'll see like clang is actually really just a very very awesome library that you can use for like reflection on steroids and reflection the sense that it's not reflection of your current program but reflection of some other program and you have the entire power of the compiler which has a lot of power because it needs to actually compile your program all right so very quickly about me and I wanted to keep the slide like short so I compress my entire CV into one word so I'm a second year student in Munich and right now I'm at Facebook doing an internship I just start on Monday and before that I was at an AI started before that Bloomberg before that at Google and after I'll be at MIT during a like machine learning research internship and so my interest I don't like schizophrenic between C++ and machine learning all right and so jumping right in so this talk is about climbing of course but I nevertheless once you give a bit of a sweeping overview of LVM because I think it's a very interesting project and because I think it's also good to know where client tooling fits into the entire compiler tool chain so we we know where we're actually entering the pipeline so LLVM is a toolchain for compiling and once upon a time it stood for low-level virtual machine it doesn't anymore now it's just an umbrella term for a number of different tools and projects built on top of the LLVM stack so you have the lgbtq bugger you have the opt optimizer which is really the core of LVM the LLVM linker and eb ll JVM which compels C to Java bytecode and I was like those people exist and there's a bunch of program languages of course built in top level of VM is how you have clang which doesn't have its own logo unfortunately you have a swift which was also designed by the designer of LVM Chris Lautner and he worked at Apple for like 10-15 years now he works at Tesla as the VP of auto pilot software working on electric compilers and the funny thing is actually that Tesla uses GCC so too bad for him and then there's also rust and even Center flow so the googles machine learning library uses LLVM to compile computational graphs for machine learning to like fuse operations and just-in-time compiler things even and they're distributed like on very many nodes so LVM is really awesome there's of course loads more projects on languages built on top ability then I'd like to talk a little bit about compilers so of course is not supposed to be an intro to compilers but I think it's nevertheless interesting to understand what clang actually is and what LLVM is and where we're actually working so in general nowadays compilers have a three phase design consisting of a front end of an optimizer and of a back end the fronton is responsible for parsing so tokenizing your code lexical step and semantic analysis building an AC yup the optimizer will then take an intermediate representation of your code and perform lots of optimizations on it hopefully to make it faster and leaner and then the back end is responsible for taking that intermediate representation and turning it into architecture or target-specific machine code or object code then the basic benefit or most important benefit of this three phase design is that if you have these three separate parts you can have many different front ends all using the same optimizer and back end you can have this you can have many different backends all using the same optimizer so intermediate representation so this is actually really essential and crucial because if you didn't have this just in this case you would have to have nine different compilers for just three languages and three seconds or is in this case you can add any back-end for like some new microcontroller or like some new system you might be developing which actually turns out most people using IBM deal so you have lots of companies to develop like a six or special chips and they use LLVM to compile stuff to these specific targets and of course you could have many different front ends for your own language from the languages and so on now a little bit more about LVM in this case so in the case of clientele of um the front end is split up into the lexer and parser at this point we will be dealing with c or TPP or dot m subjective c and files as well and we would be flexing it turning into an HT then the optimizer is really a set of passes and at this point we would be dealing with ll which is the LLVM intermediate representation of files and also dot BC which is a bit code representation and this is actually the core of LVM and the core benefit and so DCC actually only got this very late and only in the past few years this into intermediate representation because and it's really very important for all of LVM and so in case of for example the LVM optimizer would have cons prop has which would try to plop constants throughout your code and then Li TM which is loop independence code motion which tries to take declarations a loop so you don't do it in every single facet look like if you're declaring some constant then of course in lining and loop under one so these will be passing through I think there's like sixty two hundred passes running every single time you run clang and that of course is very important and then the back end of machine dependent optimization and will emit zero or dot s files so machine dependent optimizations is basically the idea or the goal here is to take the intermediate representation and map it as efficiently as possible to the target architecture so for example in the case of like x86 or ask architecture where you have instructions for everything like copying a register to another register and AES encrypting your hard disk and tweeting about it all in one instruction the goal here is only to take lots of instructions and mapping it to a single one on the target architecture and then also doing things like register allocation which is actually very interesting and difficult problem or in a program you have lots of different values alive at different times you need to map them to registers and the case of x86 which has only very few registers very hard and then in the end you have Dakota's generation where you omit the actual assembly code or objects house and then pass it on to the linker and we'll be dealing most we have front-end of course because that's what clang is clang front end now looking a bit more closely at clang and let's look at what the lexing and parsing steps would do in the case of clang because this is also where we'll be operating this is our playground for today so the lecture what first of all take the C++ code you just saw and tokenize it so split up and so take these raw characters and split up into many different annotated tokens so in this case here we have like keyword for template we would have the LS token another keyword identifier is and so on and so this is the output of the lexer and at this point i'd like to just jump into some code and also one goal for the talk today is just to give you like a very sweeping overview of the clang LVM code base so can people see this all right so this is this is clang and it's actually a very very nice and beautiful code base so given the fact that it's almost 15 years old it's probably one of the best maintained projects out there in the wild and seriously like probably top three or even the best one it has very clean code it's very well optimized so how many people saw a Chandler's talk on like LVM data structures a few years ago okay so you'll probably I also talked a bit about that later but so the only quirk is that variables are uppercase or capitalized story which is a bit of a problem if your class has the same name as your variable but other than that it's actually very nice code so you can imagine for a lecture this would end up being just a very large switch case statement and it really is like this it will switch peas and so for example if we were to read the our token then if this is a C++ 11 compiler our could mean raw string literal so we would try to like some more like try to see if there's a this quote symbol afterwards and otherwise if it's not suppose 11 it's just a normal identify character and then we have that for all other kinds of characters of course okay so after the lexing step we have a stream of tokens and then it's the job of the parser to take the stream of tokens and build an abstract syntax tree out of it so in this case we out of this the function declaration from the code you saw before and we would have a seat XX method nickel incline criminology and at this point also remind yourself that clang is not just a sequel source compiler but also AC and especially objective-c compiler which is probably the farthest from C++ so everything that super fuzz related has a CSX in front of it and you would have a method that whole then you would have in this case a return type a parm VAR deckle and the Const with es console because this is a member function then the pine board echo would have a default argument would have a quad type and identifier and the Koala type would have the type inside because a koala type just adds like cons for volatile qualifications to a type and then above that you have a c6 record echo and the record is a struct class or Union and then about that the the top level will always be the translation unit deco and then you have lots lots more beneath that and this is actually nice because the clang clang is a very rich ast which you can access which you can work with and which you will like to work with later on now once we have this HT the next step in the LVM pipeline this is actually also where we're stuff is taking this HT and transforming it into LVM intermediate representation so this would basically have something walk the AC and for each node in the HT amid some LVM and this actually also so this is if you were to write your own front end at this point you could stop because that's all you need to do as soon as you have some way of transforming your quirky brain-fuck language into LLVM committee representation that you can use the entire power of LLVM you can write that to any back-end you can use all the optimizations and that's actually very powerful so at this gate in this point for example if you want to is this well let's go up a bit now let's let me show you what this it's readable citation looks like so I have this test file here for example it just has a function and if I wanted to emit LVM I have this command here - SMI submit LVM and this will I met this test l ll file and we can see what this actually did so in this case this is very unauthorized if I actually turn it to like oh 3 there would be literally nothing left because nothing is actually using this you can also see that there was this class which no one uses so it's also gone but what you can see here is that the elevated committee representation is actually a risk instruction set on its own so it has some nice properties like it's strongly typed it has some higher-level constructs like defining functions or calling functions or returning from functions because that basically obstructs away the calling conventions that you would have on a normal architecture and then you also have infinite registers so this is also a big one the reason why it's a virtual machine and on a real machine you have infinite registers because that makes analysis a lot easier so whenever you would like increment a variable like we did appear like this plus equals 1 that would actually store for example from 2 into a new variable % 3 because that makes it easier to understand what's going on it's basically like if you were to split up your program into lots of different declarations and each one were pumped it's of course easier to understand what what each one does I even though it's maybe a bit more verbose okay then we let's talk about more about the clang HD so this is what we'll be playing with today so we have this statement here and there's four major classes when we're using client the first one is statement so a statement is a lot of things so in this case for example we have an if statement which has a condition that is checking and some code in between and I like to also show many here some some doctors and so clang doesn't have very that much like inline documentation but the docs engine is very nice so you can see there there's a few statements a few different kinds of statements and a statement would have four exam in this case we have have an if statement and an if statement has something like a condition expression it has event statements which is anything inside the after the F it also has a corresponding else statement and we can get locations and there's also this interesting yet in it does anyone have an idea why if Clause would need an initializer yeah exactly so like if we just pop up like this if statements here and we can see that for example say you've never seen this we could have some some if statement here in C++ 17 where we declare a variable and then have a semicolon and then actually check some condition after the F close so this actually very nice new feature that I encourage you to use with clang of course and yeah so that's that's what you would be dealing with and there's of course a lots a lots more beneath the face team then after statements we have declarations so declarations could be anything from a class declaration variable declaration function declaration and also if we go to the doc surgeon for deco it's even even larger so there's really loads of different declarations and anything is from like declaring and enum I think is somewhere here the name declarations which be like classes and then even here there's value declarations and then if we're actually interested in like looking at the rejas open and actually like fields of variables there's even more behind this so LVM does use the inheritance and polymorphism a bit and quite actually quite a lot so now you'll see this very much I'm suffering here way down the inheritance chain you would have a field operations at a class or you would have a variable or a function and that's what you would be working with okay then after declaration you have expression and this is actually a bit of a quirk inside the decline architecture that an expression actually derives from statement so intuitively this doesn't actually make sense because an expression is not a statement you would think that a statement has an expression and it's terminated by a semicolon but that's the case so for example here the condition would be an expression and also the spring literal would be an expression and by the fact that expression hurts from statement also means that you can't actually represent the semicolon like the no op in like in clang like there's no which axe represented i which is a bit funny and yep no because like you were basically like if you had it with a so the question was it doesn't not get represented in the AC at all and believe it doesn't because it like if you had the e has a relationship you could just state it like no app would be a statement without an expression so in this case I'm not sure what it does but I know that it can't be I represent it very well inside the AC and the last thing then it's types so types are also important especially in C++ and in this case here we have a con scare corner type declaration and then beyond types you have koala types so a koala type contains a type inside and add some qualifications and we can actually look at this if it's quite cool so this is actually more related to Chandler's talk that I mentioned before and so if we go to qual type then this is this here is really the like this is the entire LVM philosophy that time to talk about in this talk in one class so a koala type I basically have the pointer to a type and this is also if you remember the time I said that if you have big objects like types that you use everywhere in your program then sometimes just a good idea to actually allocate them once and just have pointers to them and that's what what LLVM explained you and then we add some more quirkiness so first of all if you just ignore this in-between here what this point to impaired is is it uses the lower four bits the very point is if you don't know like malloc usually allocate some 16 byte boundaries so the lower four bits are up for grabs and LVM does grab them so here we have a pointer in pair the important area is to the type and then we can use the lower four bits for concern or consult our non-volatile and additional qualifications so that already like saves us some some space and then the next step is that if we needed more policy clear qualifiers then we have a pointer Union which would actually instead of pointing to the type what instead points to an external structure which contains the type and more qualifiers so like in 99.9% of cases you will just have this one point in using the lower bits but if you need more then you can just then the same pointer will point somewhere else and so that's actually really matte like maximally space efficient which which is very nice okay now we get to flying all the things talking about more about Clank tolling I look lying I look tooling and then we can spend the rest of our time looking at some code so the first thing we have in Clank tooling is lip climb so there's these two basic libraries there's lips lying there's lip tooling lip flying is the C interface and the one thing that's special about lip slang apart from it being in C is that it's a stable API so one of Chris Ladner's the founder of LVM and general ilv employees philosophy is just to break all the eggs so whenever something needs to be changed in the intermediate representation just just break it break off everything that depends on it because we need to move forward and the reasons like that's good for the for the project but it's bad for everyone depending on it so for this case if you're like developing an editor for example you don't want to like update your code after every release so lip clang is the stable C interface so let's clang basically never changes it's probably was like designed once and it has a clean interface that won't change very much in the next few years so if you're writing an editor you can use lip clang and and rely on it not changing that much so here's some lip line code and we'll walk through some real code after but just to give you an idea lick clang has this basic concept of cursors a cursors just like a pointer to a node and then we have visitation so one thing I forgot to mention about these different like extra and diksa land type nodes is that there is no common ast node in clan so there's no like base class for all kinds of notes and the main implication is this that whenever we want to walk the ast we're never going to be able to just like have a function like this here and see whether we have a cursor or we can take any kind of note so anytime we want to walk the HT in the C++ API we're going to be using be using visitation so we'll have like a class that we override and then we override this at Tech Cove as a type is it statement it functions and that's actually a very important part of time as well so in this case we will have a cursor which is just a pointer a node we would be getting its location checking if it's the main file or not from system header and then we were getting beginning in spelling princip's and then improper ra íí- session disclosing it and then this line down here just tells it to workers and we will be giving us to some little capi and it would do most of the magic for us another thing that's cool about lip crying is that it has built-in code completion and there's actually very important because literally if you want to like get code completion for your code there's one function called code complete app which you pass a buffer and pass the location and it will tell you all the possible completions at that point so what we're client does here is that when you tell it to code complete app it will insert a special marker in the HT and then when it parses and and reaches that specific point it will use all the context it has all the like you know everything it knows about the ast at that point to give useful information about how you could complete the code at that point and so there's those functions and a few more like very nice high-level functions and also what's nice about lip sign or maybe nice is that it has a Python API so this is the exact same code in Python you know not saying anything not saying that one is better but this one is quite readable it's also like it's in more high-level and this is probably useful because lots of editors like I think sublime uses Python and Adam use JavaScript so having like scripting languages on top of the C API is actually very useful then we have lip tone yeah and so question was if there's a C++ API there is but not for lip client so looks fine is like the C API and then there's a very powerful lip tooling library which you use for everything else and that's when you're looking at and so lip tolling is the C++ library and one thing to note about lip slang is that because it's so stable it's very high level as well so even though it's nice and like if you can achieve something with lip plan I would definitely try to achieve it with a lip plan because it's less code is it's usually easier but very often you'll just get stuck because there's something want to do when the tongue doesn't expose it and that's where usually want to use lip tooling and I actually also prefer the tooling is it's C++ in it and it's a lot more powerful so with lips tooling and we're going to look at some code in a bit but there's three basic kinds of doing tooling the first thing is client ID so how many people here know clench ID yeah so the first way of adding or writing a client rule is to interact directly with client ID so here you would basically be adding a new plug-in to client ID and be adding it to one of those checks the nice thing about this is that it is abstract away load the boilerplate but you're also bound to plain tightening and you can't just have like an external tool and then we have client plug-ins so clang plugins are essentially the same as the last one which is plank tools except of the fact that expand plugins or dynamic libraries that you build and then you link into expand when you run it and it's also a bit more complex to actually pass it to Kline but the nice thing about like clanging plugins is that you could just for example put it into your like Bill tool and would run checks when you compile and make sure that you're not like violating any like lint or errors anything and but the last one is writing a client tool and this is actually what I prefer doing which is really just writing a standalone executable using client library and it's really cool because you get a standalone thing that you can drop into places and you have all the power about the like you actually have a main function so in the case of client plug-in you don't have a main function so you can't do like firstly you can't keep States in some cases but you also can't do like emit some jason at the end or something because you don't actually know when it end so lips applying tooling gives you all the power excited clang tool gives the elbow power alright so this this picture should tell you that we're going to have some fun now and so i bought a lot of tools and actually I brought too many tools so I'm gonna add so much time in the train here I decided to make this slightly interactive so I made this I hope this load I made the stupidest HTML 17 a website where you can actually like vote you're going to be voting now what tools you want to see so please bring out your phones and bring out your Wi-Fi I'm just going to walk like briefly describe each one and then you can so that this HTML 17 website has a REST API of course and then you can vote for it but so let me just like walk through each one so ast down to the first one if you'll use this lip sign for the C library and it just dumps the AC so what it does actually is if we have some code here yes so if like there's this asked jump I thing you can do with clang which is actually very cool and it basically just dump the AC with all the information about the types and have variable names and everything and ask them would be rewriting that in the plan which is actually very educational because you need to you'll see how we can access all of this information with little claim so that's the first one and the next one is TPP grep so sometimes you might have this problem like if you have an editor and you want to look for the word I know like class it will be everywhere but like you have a class keyword you have class comment and easy if you have some variable name I don't know fill you might have a class name too and everything names - so what CPP grab does is it's also using what plan it's like grep but you can actually like filter by functions like C++ functions or C++ records and so on so it's quite cool then dick check so a while ago I was working on I like programming University and my my fellow Co levels weren't so fond of readable variable name so I because I was a team lead like I decided to write a tool that would run through their code and make sure that every variable is a word in the dictionary so take check that it's actually very short and fun include sorters you can imagine what it does this is a dick check and include sorter include sir just sorts includes are both lib tooling and then 9 - tool is more of a like educational one to show you how Diagnostics work in plants if you're interested in how diagnostics and fixit's work that one's pretty cool then use override checks that you use override on your message so this is more into the region of like making sure that you as a developer like a write safe code and a virtual destructor make sure you use like virtual if you ever arrived from the class even if you don't Excel the constructor at all and using lip tooling on clan variables is if you're interested in how to like do some extreme kind of matching that you want to find so plan actually sounds for once lambda that takes an other variable is declared no accept and have to go to inside so if you want if you're interested in like finding exactly some like particular node this tool is quite interesting CVP grab pi is the same thing as we grabbed but in Python and like half the amount of code enable if checks that you use enable if underscore T instead of type name enable us so it's more like modernization which is cool and Maccabi this one is quite nice it have you ever heard like macabbee computational cyclomatic complexity so like this is basically it's a measure of how complex your code is like how many paths are through your code it's actually very like interesting to know because if you have lots of like if clauses in your code and you should probably reflector things or rethink your design so if you so this tool actually does that it sounds very complex but it's just like three lines and but it also shows you how to you access the control flow graph in clang then we have pointer finder which finds pointers and so previously I was a Bloomberg and implement we have this this this style rule that every port dress be prefixed with P underscore and so there's this this tool finds all pointers make sure they're prefixed and then using resist Isis finds all types and recommends to use using statement instead okay so the way we're going to do this is so this I am unfortunately not at the time to register a domain name and but so if you like people to um yeah let me just so this if you suppose the URL and I'm going to like put it let me just join these two here alright why is this Twitter okay so if you follow that URL and then do the load and it / 1 2 like the these are the the bold like numbers here and if you type that and let me just show you if you type that in here and then it makes load now it does not explode so it basically like thanks for voting and then if I reload this page I just voted alright so just do this and like just anyone see you'd see this this IP address and just a comma separated list of the numbers in bold and that will make you those yeah they don't don't cheat down vote and don't beat up my server yeah as I just yeah so it'll just do that for like two minutes of me anytime oh it's loading various well okay a worst case I'm just going to pick some like Dixit oh really but I thought this would be fun is it so funny yeah okay it is still lives I see indeed it okay so it let's just wait like three more minutes and then meantime if you have any questions I'm happy to answer okay I think people or does anyone need more time you want the bold numbers so that so the I made it so that they don't actually change that you don't have to like look where everything moved even though the rank actually changes yeah so I think if this manages to low then we'll just pick it out oh I should have started this probably I see more times okay okay so let's just stop here thanks for your vote I hope democracy is like democracy the nice thing as long as it doesn't get trumped as president sorry yeah it says like thanks for voting and the tool that you pick alright and okay so we have so g PP grab and Maccabi and flute sorter and son alright so we'll just start with cpp grip and yes life very live so live I guess and GPUs but okay so this was a little anger they said and just start at the very bottom it's reasonably lots of code and I'll just walk it walk to it and so let's plan for so sorry LVM has a very nice command-line library and it's actually like the nicest one I've seen so far the only like detriment is that it uses global variable so everything so if you're linking with another library that also Clair's flags you'll have those flags as well and but nebulas so the first thing you always deal with lip clang is create an index and index is like a structure that will manage all your translation units for you and then you can also use precompiled headers which makes your code a lot faster or your your parsing a lot faster of course especially for like standard headers and then so the what this tool actually will be how you give it let me just go here pc prep so so i can say at this point i've spent a significant amount of my life trying to compile LVMH lines like if you made a pie chart of my life the slice will be visible so I've now moved to just using a docker with like the LLVM libraries and like install yapped so let's just let's just show you what this does and so cpp grab the way you will use it is like some pattern for example and then the file and i will just show you like the lines energy and then you have like you can filter by functions you can filter by members parameters records so classes are structs variables and if you make it in case insensitive so that's what we're building alright so then for every file we're just going to read the lines we're going to need those lines later on because we want to find like write out the entire line where we found a match and but that's just a detail then we have this parse function and parse what parse does is it called clang parse translation unit so this is a very important function because it actually like gives you back the entire AC so this does all the parsing you pass it this index you pass it a filename and you can also pass it some buff so this is important if you actually have an editor and you have some unlike son stored buffers you can actually just pass those buffers to clang it also parse those for you and then at the end we have the CX translation unit which is a cursor and as well and then once we have this translation unit we can get a cursor for and then call clang with the children and this is this important function which I showed you before which is the actual vegetation so this will walk the HT and what you do with it is you pass it a cursor like the top-level one usually the translation unit and you pass it a function which is further out there and he passes some data so data is just like void star type arrays C++ or C polymorphism style and the data here includes the filter and the lines and the filter just in this case like it has on some predicates right so you can imagine we have fun we have like some code we want to pass it through some filters and see what put if it still matches those so we have we would have a pattern which is like a regular expression and we and then some predicates which are just functions that take Ackerson returns for false and the where we actually declare them is inside this function here so this makes Hilter I would recall to our beginning it will check all the options in the global scope of course and then add some filters so for example if we only want functions then we would so we would get the cursor and we would get the kind of the cursor so every course of the kind and a kind is basically the DC abstraction for like Dec whole or statement or expression and then we would check in this case if so if it's if we want it to be a member then member functions would be method so we will check if the kind is the exist method right otherwise we will check if it's either a function declaration or a method then for a variable we would check if it's if it's a member of variable member variable means field so we would check if it's a field otherwise check if it's a variable or field a parameter checks for particles so all these know that you saw before they are also inclined and this one here like if you only pass memory will look for all functions and fields automatically so field or methods and for records that will look for all structs or classes so these are all filters and it what we need to do now is walk through the AC look at every node and just ask your filter doesn't match and this is what egrets function does so this is the what we pass through this clan with children function we get a cursor this here is the parent which we don't need in this case but we would have that and the sports star client data so the first thing we do down here then for example would be casting that back to our data foreigner so we could access or stuff before that we just check if it's in the system header because if you write any tool and you forget this you will and you include a standard header you will get loads and loads of different matches for everything which is very bad because I like yeah it's a huge AC and then so we would get our data data includes a filter we just ask the filter if the cursor matches so this was also this will also check and one filter which is the pattern filters let's use a C++ 11 meraxes and we get the pattern is from a command line and we would make a regular expression and make it possibly case insensitive and then just add that as another filter rate so we and then to actually check it we would call get cursor spelling so spelling again is just the name of whatever is or notice name on the function name of the class and then we would just do a record search and see if it matches and that will be our like one of our filters so if we go back to grips we will check if it matches and if it does match all we need to do is get display it and so here we need those lines that we also have in our data but what we first need to do is we have a cursor we want to find out where in the file is the sorcerer so we call this funky function called plan get spelling location returns to us line number column number and file and then after some assertions if we have more than one file we also want to display the file so if I actually pass the same file twice and we would get the file name there as well and we would print the file name and then some escape code this probably won't work in Windows but some escape codes but then the line number the column number and what this here does is and yeah so this one here it said gets a line from all the lines in our file then it won't run through each character and if we get to the actual like note that we matched it just throws in the escape code so that it turns up red and bold and but essentially that's all there is to it and then at the end of grep quickscope we call we return seek shadows for Chris so there's three different things you could return here this one here tells clang to continue or cursor to the HT then there's six child visit continue which would tell it to go to a sibling so for example if you are the function and you figure out you're absolutely not interested in anything below this function like the statement inside you can just continue to the next sibling which is the next function or you could just take Travis break so just stop at this point and like bottom up again yes see you see you get it see ya method I like it and I think you see it's customary to have your functions have 20 like parameters and then return it yeah absolutely I mean also also like this function here's is way too long of course that's actually one thing that's like I found this like code a guideline from LLVM quite interesting if you have lots of parameters you just put like in line that like Python keyword Cell arguments there's actually quite useful and anyway that's that's actually I believe all there is to this one here and so we would just print the match and then if we try this out so here we are we have I can like compile it again I'll just take very long the reason why it takes long is that wait this was supposed to be more impressive and this is why this is why it takes very long to link so this is all the LLVM libraries you're linking with here they're just all in one library but it's still a huge amount of libraries are linking with so it takes like like a minute we don't have that minute and so if we now right to use it so we have test TV and so the point of this tool right is that if we just do a grep on this and we want to look for all X's we're going to get like X all the x's like if I had comments that describe what X is I would get the comments back so what we do instead is we call a CPC grep and we say that we only want functions that are called X and so what does it deal so let's just like walk through it very briefly it would like go to have a function option so without the function filter and the regular expression for X and then here appear and the grep function we would just have like two filters which are called inside the filter class like so it first checks the pattern if no filters are passed it just accept anything that matches the pattern otherwise it checks as any of the filters pass right in this case the the function filter passes and if we also wanted to include like variables in here we also get the variables so this is actually quite cool I don't know I'm sure like some visual studio editors or something do this as well but for then people other Adam people this is not there so this is the first of all yes yeah yeah yeah you have so I didn't actually do this here but like this these command my org so you would want to fill this out in practice so you would like pass - ii and i - i sorry and like the directories gonna it actually won't find the system headers and which is which is a problem because the sorry the question was can you passing foods and it won't actually find the system headers because so the reason why clang Sciences matters when compiled is because you're using the clang driver which like knows everything about your system but here using what clang directly so clanging does nothing but like what C++ standard headers are just some headers and see what else need to pass those yeah yes the question was about it I'll know about the system headers and it does have like this stuff here so you can check so like this is like planning the strike to tell you whether or not it is the system header and you can also even even check like whether or not a note is from the supersoul standard library like knows about that as well and so yeah you would have to you would want to check this there's also like is in main file which checks if it's in the main silence is like a system header let's say yeah that's possible yeah exactly and that's also possible okay so I think the next one was my cubby so this here is the tooling so it's actually good that when you switch to this one as well and so this is a C++ API which of course is a lot nicer and and the cool thing about like blip tolling is that you're not actually like there's lots of levels of abstraction that clang has added on top so let's totally developed primarily by Google Munich so Chandler's team and Chandler's team Munich are using like doing huge efforts to make tooling very easy and so there's always like flying tooling libraries here and yeah so let's just try this out so we would have the clang tool first of all is made up of three distinct things you have an action you have a consumer and then you have some kind of a callback so what an action does first of all it was just what I walk through it an action allows you to access the HT at several at different steps during the compilation so for example in this case here we will have an action and we could override begin for sell action which would be called before every file so at this point we could like look at the compiler instance and like get options of the compiler so in this case for example just to show off what it does you could ask the compiler for the language options which are like it's equals 11 even now is it are we using msec I like support it also knows about garbage collection on or off it knows about sine overflow so for example here just to like show what you could do you could access the F sine overflow defined or not so there's a command line slide you could change this and you can also access the file name and then at the end there's also any source file action and in between there is execute action which we didn't overwrite here but it does call create ask AST consumer and here we're just creating a consumer and then later on clang will just walk the AC and with your consumer and call the consumer at various points in the AC so next point would be a consumer so that's like next step and pipeline and there's a little bit of boilerplate always associated and this is actually exactly the boilerplate that clanked ID got rid of so if you're running a client ID check you're just going to be writing this or like the main point here but here again the idea of like writing a plant or a lip tooling tool is that you have the main function so you can do a lots more things you have lots more power so the next step was the consumer and the consumer here is using or it all it really does it creates a matcher so what's lib pulling or a clang tool in general is really really good at is it's finding a very specific note in the F T so if you're writing like a style checker you want to find corners clang gives you lots of possibilities of finding that exact like note in a tea very efficiently and effectively and for this client actually has a domain-specific language under the slang HT mattress library and it has like these macros where you can define almost like an in plain English what you're looking for so for example in our case we're looking for all functions we want to compute the complexity of functions and so we were looking for functions that are in the main file so this is like in system header the opposite is in the main file and then we can bind some these nodes to variables and later on we can access them then we create a match finder which is part of the library we add the handler which is we head up here I like on top to the matcher and then inside handle translation unit we will just tell clang to run or handler on the HT so we instead of like handle translation unit there's also a few more points where we can access the AC like handle like inline function declaration handle V table declaration and the point here is that at this point the ast is already parsed so we can access it at several steps and then the main class is this match handler which is also part of the ask matches library and it will be called for every node that matches this expression below that we have for the functions and inside here will be actually computing the computational complexity and for this actually for this particular tool I have some more slides I have one slide all right so what is cyclomatic complexity cyclomatic complexity generally computes the number of paths through a program so if for example in this case here we have a very basic eight clause and this was the control flow graph for the disk clause so we have some start node and all these nodes here are basic blocks so if you don't know what a basic block is the basic block is any part of your code with exactly one entry point in exactly one exit point so it's basically any piece of code that has no control through in it and then if you have a control flow graph the nodes are the basic blocks and the edges between the basic blocks are the control flow so for example this case the first node will be in x equals F and up to X greater 5 that's the first basic block then we have control flow so we have an if statement and here the x equals one or an else branch and then they both join together back at the return X and so in this case here we have two paths from start to end I like the left path where right path and now if we added more complexity like here I just added one if clause that's where add and then we get another path so now we have three paths here and so the cyclomatic complexity or the Maccabi index for this function would be three and if it's like if you add more control so it maybe becomes like more than five more than six at that point you may be like want to try refactoring or like rethinking your control so and so one interesting way of like thinking about this number here is that if you think of the minimum spanning tree through this graph so like if you think of some tree that passes through every node but like with no cycles so rental in this case you would have like this similar so yeah so this path here and this path here so this like here is one minimum spanning tree then all the edges that are not in this minimum spanning tree are additional paths and additional complexity so like this if there was only this e Maccabean X would be one and for every edge that's not in this minimum spanning tree MX having n X is one one greater which is you have one more path where your program so you have like this path or this path or this path and so the way we compute this is actually extremely trivial so we have this match Hamlet we get a match result and the result contains most importantly the nodes that we bound so for so here for example we get the result as a node and we can call get node as and access some note that we previously marked for example like here we had dot F or just F n so we can get the F n node and we can get it as a function declaration and once we have this function there's this nice method called diltf G and this builds a graph consisting of basic blocks so if this was just a bag of basic blocks in the order that they appear in the control flow and so we get this control flow graph and all we need to do now is compute the number of nodes in the number of edges so yes that friendship it just gave one you done with my cake without constructing all the graph structure that you are doing that my sorry the question was you could you just count the number of if the number of well clauses and its yeah like I mean intuitively it sounds simple I'm sure like if that were the case you you would do it but yeah it's for that for every branch you get one extra level one extra path and for every well statements and for well statement there's a few more nodes because you have like you have the condition then you have the loops back so it's maybe a bit less yeah yeah yeah yeah so I'm sure there's ways around it there there's like a formula to compute those members basically just a number of edges minus the number of nodes plus two times the number of components in the graph so component would be like if you had many many functions there would be many components of the graph in this case it's just like two times one because there's one component and then we need the number of edges or number of nodes and that's all we're doing here like number of nodes it's just the control the size of a control whole graph - - it's - still because flying as an entry and an exit node at the end and beginning of the CFG so we'll just subtract those and then we just iterate through the basic blocks and for an count the out degree so the outgoing edges for each block and that gives us a number of edges in the entire graph and once we have that we can compute those complexity and then this tool also has like a threshold parameter we check if the complexity is below the threshold and return if so and otherwise we omit a warning a diagnostic and diagnostic is actually very cool and I even wrote a black blog post about it so Diagnostics allows us to use all the power of planned Diagnostics for round tools and as we all know planned Diagnostics are really awesome there are a lot more awesome than GCC Diagnostics especially for templates and we have a lot of power here and it's actually very fun to use it yes does this have a large number of control quality goals with certain exceptional groups through your code this might be enhanced but Peters quest so the question was if you have anything else and they create a large number dental control was you've got something taking returning by value yeah I mean I'm gonna mention like if you had an exception that would be like an outgoing edge will be like an exit no yeah so that would most likely like that would be an extra level of control flow as well I would suppose yeah yeah how do we yeah I mean you can try it out yourself so what we want to do here is it diagnostic and for this we let's just see how you do this so Diagnostics you get a diagnostic engine from plan Diagnostics engine basically gives you access to all the Diagnostics power and then we get a custom ID for eye diagnostic and this is actually important because clang has a lot of its own internal warnings that it can like has like parameters I can reuse in certain different scenarios and in our case also we need a custom ID we also passes like severity so you could have like a note you can add a warning or error or fatal in this case is just a warning and then there's like a like formatting like library here as well so you can say a function with a name is too complex and you would pass the complexity and then we get a diagnostic builder from like this report function where we pass the location where it's going to point the carrot and the ID and then we add a string in this case a qualified name of the function and we add a tag bell with a complexity so this tag Val function is actually quite quite funny because it takes either a pointer or an integer so again as you saw like LVM is quite loose on the boundary between pointers and integers as long as it's fast so this function takes either a pointer or an integer and you need to tell it if it's a pointer an integer and but essentially and what we get at the end of this is if we go here so we have some function right so we have like a function s here it has one path so Maccabi NX would be one it has a function G that has one unit of control flow and we have a function f that is way too complex that you want to like change right so this could be your code and then we can call Maccabi on this CPP and there's also like a threshold parameter so if we just set it to zero for a second and then investigator would for each function computes the Makati index if the index is higher than our threshold it just emits a warning and you can see how nice client diagnostics are there like even as colors so we have our message here the phone's the name of the function is too complex and the index in the parenthesis and then also the current pointing at the function and then what we could do in this case is usually you say like a threshold would be like 5 and then only those functions that have that our too complex would actually show up and if that's where your code you would probably want to think about rewriting your code in this case and this is done with the heart here was just to show what you can do at the end of the action so like you can have an end source L action at this point for example if you're writing a for source transformation tool like line format this would be where you like print out the changed file ok um how much done we have list okay we can do at least one more I think so we had what's the next one include sorter okay as any fluid sorter I didn't actually think people were interested we get a client format of that anyway but it's actually cool because include sorting means we only deal with the processor so this shows you how you can access the preprocessor and look at like if if this or in this case include a directives so we have our boilerplate again like clang tool we have some options and in this case we have an action and only one pre-process one consumer so there's no there's not three nodes in this case it's just one and so we have an action and we have over option to sort or includes or so in reverse order so we'll just pass that to the action and then we have begin invocation so this I didn't show the for but before begin source file there's also begin invocation which is called before any file is even touched so in this case here what we do is we get a rewriter so client has this nice rewriter data structure which is a like a fancy be tree which allows you to like it implements a rope and allows you to rewrite your source code very efficiently and so we have a rewriter we tell it the source manager which manages all the translation units in your code and the language options and then inside begin source on action what we're going to do is create our callback so this is the class above and then I get to get the preprocessor from the compiler and just add a PP callback and that's really all there is to it so we add this callback and then what we can deal with this callback is enter the pre-processing at various stages so in this case here I overrode including directive but you could also override like if overwrite if deaf so if you wanted to do some fancier analysis on the preprocessor you could do that with the PP callbacks in this case what we want to do is we want to include sort in fluid so one thing we have to think about here is that usually like in this case or many people like to sort their includes in like blocks so our algorithm here is going to be look at every include directive look at the line and if the line number is more than one from like the distance is more than once in the previous line we have like a block so sort everything we saw up to there and then rewrite the source code for that particular book and so here's the fluid data structure which just has a file name and tells us whether or not it was like angles or libraries inclusion and then the actual call back here okay so it gets the location of the include gets the inclusion token which we are need here the file name whether or not it's angled the range of the entire inclusion directive the filename absolute path real path and the module so plan actually already has like support for modules in this case this was already there before so it's just a more of a general I give it like some unit of code well yeah so what we have here then is we get the location which is the location of the hash and we check if it's in the main file is not we just return otherwise we also stored all the standard includes which is there's too many and then will your sequel for 17 to gets the foul ID and the offset of the location the reason we need that is that we later on to get a line number so we can check if the distance is more than one so we get a file ID which is just like the identification for the file and the offset from the source manager so that's what the source Android is good for and then we call get line numbers with a bit nicer than you saw before in lip clan and we just passes d file the offset this this year is of course not very automatic but like we also pass it an output parameter just check it within her but anyway we get a line number and then here the idea was that either if we so if we don't if we already have some includes and if this line number is greater than the last line number plus one then we have a block in our include so four sisters and here we have like this vector of includes at this point I just want to like shout out for the data searches inside LLVM they're really awesome because they actually give you as a developer lots of options and make like conscious decisions about the data structures you use and I think I even have so like quick the regression I even have this open here so these are all the data structures you can use inside LVM there's a lot more than the nasty ones and in the standard especially crash tables and but one very common optimization see in LVM is using small things so here you just saw a small vector and the idea is like the small string optimization for Springs you just allocate a fixed sized buffer and if you need more than you allocate more space but for example you have like small vector you have tiny corner vector which I really like it either stores yeah it has it has a pointer and it can either store like if it's 64-bit system you can either store eight bytes like a container for 8 bytes or review that same pointer to point to an actual data structure then you have like kid well some like lots of small sets spring sets dense it's AZ index map D trees twine twine is actually very nice it allows you to it builds like a like a tree of temporary expressions so that you can like concatenate lots of different strings together and turn them into an actual spring at the end I think of an example later but so let's just go back here so what we want to do is if we suppose to say this is the first include we get the location of include and what we want to do is we want to record the first location and the last location of a block so that later on when we sort them we know water to replace this sort of includes and then we in place back the filename and whether or not include was angled and we get the last line number and the last location just that we can do this more efficiently here and then so for the next include is this if a new include had a line number that was more than one away from the last one example if we were if we just got to this one here that means that currently in our include vector we have all of these includes and we want to sort the includes so to sort things we call sort currents which calls sort includes and this function here it just basically takes the vector it includes and so here is a small vector info so if you saw Chandler's talk and data structures you know that Olivia Mike's use polymorphism and to do lots of its small observation so for example the small vector actually derives from small vector input which means that you can have this this small buffer inside the small vector but when you have the function you can just take a small vector in pull and the whole buffer is actually abstract it away so this is actually very nice so we sort of includes either in reverse order not reverse order again these includes or this data structure up here we sort them and then we just join them all together and this is just destroying them and possibly adding angles and this excuse was awesome flying data structure and big founded so what it does actually it's like a recursive data structure so when you create a twine here it will create a temporary twine and then when you add it add like this this con secure point here it will create a next and another twine and so progressively actually build up a tree of points that are all temporary expressions so if I were to store this this list line here like that were to like store this and variable it would be complete garbage because all the all these temporary session would be de-allocated and by that point but what we can do is like as a temporary expression build up a tree of twins and at the end which is called offspring and have like one big concatenation so you would know exactly what the length of this temporary expression has built one string and just for everything into the string and that's really cool so we just sort the includes and return the joint line and then if we go back to here and we have the range from the first location to the last vacation and then we just replace the text so we just get this range replace it with this text and that's other it and like you clear they include for the next time and then the only thing that's here is that and because of the way this is structured for the last block there won't be include that's more than one way so like also at the end of the main file where we can also like jump in we also want to sort one more time so let's try it out there any questions okay I imagine everyone is asleep right now okay so okay so what's here so this is actually include some before and you can imagine what what it should do hopefully and is take these lines and sort them um so include sorter and so this is exactly what you mentioned before like what I need to pass some command line parameters I mean here I need to also tell it that it's equal size 14 and then it works okay so here it actually included as it's sort of the includes you know nothing and then just to reassure us that it actually works so we can sort them in reverse order and that works very nicely and and it also sorts them within the blocks which is cool and some people also told me that it would be nice to additionally like sort the blocks there's also something what you usually want to do like I sort the exclu the standard includes at the very bottom then like more more specific like clangs low sodium foods for includes that could be like the next step but yeah yeah yeah that's a good question I I believe it does not like create the entire HD nevertheless one thing Klein is very picky about is actually having like a valid ast and so it imagine still after check that those includes exists probably as part of the IQ probably has its own inclusion directive over like base like method which checks the thing floater exists as part of the pre-processing um but yeah it's a one one problem with this clang is that it actually needs to it actually needs to compile your code like actually it's too now all the includes and that's you know all the flags to commit to the files it might also actually also like take a while sometimes if you use a client tool like if you ever use like include what you use it sometimes takes half an hour to work on a big project yeah well it needs to know yeah sure like if it's come into play yeah we're like the standard is all free yeah definitely I mean X but actually I think that client format does some magic to work around this so client format works without like it and it actually having to compile which is actually like if you use client for Mac you also don't have to pass it these includes so I'm not sure what it does but it does something nice so that even if your program doesn't compile it still works with here if you have a bug somewhere in your code it won't work but yeah so you have to pass it everything okay yes yeah yeah yeah I'm sure there's ways around it yeah I mean one thing that's actually important to know about a Clank tolling is that very often what you what you think you would be able to deal with fine tooling is actually modified the AC we use crying tool you will never actually modify the AC you can just like make something Const or like add a node because clang has very strong invariants about this a steed has to be valid it's actually also one of the reasons why we don't have custom attributes yet because if clang doesn't know the attribute then it just like to think Stacey is a melody he'll just throw it away so this means that whenever you use client only all you're going to ever do is change the source code so for them in this case we use a rewriter to rewrite the source code and that's what you can do and you can change the source code but you can't change the HT because that might break something and there might be lots of invariants and places where you don't expect them so you can't actually ever change the HT yeah I mean there's also like nothing to stop you from actually like making a node Const or something like the methods are there that just might break stuff yeah like I mean that the methods are there like you can use the source manager to make a node constantly friction add a new child so I think that's also you might have to like reparse and I've never done it but it's definitely not encouraged yeah yeah the question is can you use custom attributes at all or not and yeah so there's actually true and it's not possible right now I think it's something people are working on and I actually provide myself to do something once with attributes like I wanted to do like a memo eyes like in Python you have this memorized decorator which tells python to put a cache in front of every function and i wanted to do that in client as well but it's not possible to attribute so one thing that is possible is that you can actually like if you have some class here where you can do it but you can use these GCC attributes like attribute attribute I think no it's it's something so many different but I can if you can do something like that and you can add a custom like tag so there's annotate is like a GCC extension that Clanton supports we can pass any kind of string and then later on what you can do and this is how I solve this this memoization problem is that you can actually look for all nodes and eivin has this annotation and where this annotation spring is this value it's not nice it's especially that's like actually good thing and it's definitely not as nice as a attribute but it is so-so but just not with those peoples was 17 attributes yet but hopefully in the future like I mean that's definitely I think one thing that she was also lasting lacking compared to like Java which has like these these decorators Python and annotations I think that's something that sequels also really I use ok are the any questions about include swimming otherwise we have like 15 minutes left might be time just like quickly walk through one more the next one was pointer finder yeah so pointer finder let me just think one thing I'm just actually going to swap because we not have much time I just want to show you what how fancy the matching can be I'm going to do the clan variables so again clan variables was the auto lambdas that have an auto parameter that are know except then I would go to inside and I also want to show you how you can do these matching yourself let me just go up here so say you have some code like this here right you have some code and you want to figure out like you want to make sure that this code has a certain prefix what you do so the first thing you would do is you do this this asked jump that I showed you for so clang ask them as dumb as some text only desktop TV and right so this is also why like exploding system headers is often ready so what we have here is the ACE for this particular function right so we can see for example and it's actually quite interesting what alumna is of course is nothing else than a class like a class of the compiler creates itself so we have at this point here somewhere a c6 I think that she this one here and it's it's probably yeah I think oh here might be but yeah so this is a six six two are critical that's actually declared right so you can see this a steam and now we ran chatted and it's finding out like how do I access this one know that I want so here I can see I'm alumni the secrets record echo and it has because this is has an auto parameter it has the the actual my call operator will be a template and then we saw you have a c6 method echo this has a compound compound statements which inside somewhere has an if statement and then a go-to statement and I think somewhere also there's like no except that clear so the first thing you would want to do is like look at the HT and figure out what nodes you want to look for and then you can imagine that like clan tooling people are kind into tools so they made a tool to we're helping my tools this tool is called a client query and it's actually very useful so what client query allows us to do is basically like interactively match on DAC so remember in this case here we're looking for and I think like all var declarations oh let me as the problem is here I can actually like scroll that better okay let's just do this yeah okay so you could look like for all variable declarations and it will look like tell you what there are and then you can ask like what more is it right so I want all things that are in the main file not in the system header and I want all variable declarations that are that has a initializer init list expression for example alright so with this tool here you can actually figure out this is very complex as much an expression that you need in this case which is here and using this tool and it's actually very important and without it it would be very hard so the boilerplate is the same the only thing that's interesting here is like the actual matching so what we're looking for here is a variable declaration and and the nice thing is that really like reads like popping so you have it we're looking for a variable declaration that is extended in the main file that has a type which is con squalus I'd like to see in a clang that has an initializer which has a type cheek six record echo which is the Malanda that is a lambda that has a function template echo because it takes an auto parameter that has a method inside which is the call operator which is no except and which is a body which is a compound statement which has a go-to statement and then all of this I can bind to the clang name right and then up here in my matter all I need to do is I get the clan variable this would be the same for the pointer final voice so I just get the note and and I get the name and I check if the name is empty because you'd have a variable without a name and if it's not empty I want to make sure that it has this prefix so the pointer finer it would be P underscore in this case I wanted to be clang underscore and then all I need to do is warn the user about it and here also you'll actually also see fixit's and so klein has this cool thing called fixit's or which actually tells you if you're doing something wrong and actually tells you how to fix it so if the name doesn't start once clang then we want to amend a diagnostic so we get the Diagnostics engine we get an ID for our diagnostic and then we create a fix it so what a fix that we'll do is display to the user some way of fixing a problem right so in this case here I want to make if I want to make an insertion because I want to tell the user you should actually have a clang underscore before the variable name so I create a insertion at the point of the variable the prefix should be client underscore and then I add the sixth attempt to the Builder and then if I actually use a client variables test dot CPP and I'm not in the darker trying levels toasty feet and [Music] okay all right and so I omit a diagnostic for the variable name I tell the user to have a prefix Glenn underscore before this and then also like if you add a little bit more effort you can also add a option to rewrite the source code in line so clang itself actually has this so if you have some code let me actually just like quickly write something this you know so if you have like some X and you forget a semicolon right so this is actually where clang really shines compared to GCC like if I compile this at another GCC on the stalker I do and so except CPP no I might not have supposed to you know say if I do this with clang and then the cool thing about flying is that it actually tells you the actual problem so what GCC will do here in this case it would say that at the next line the first character of the like next equation it would say there's something wrong like did not expect the declaration here but clang actually figures out that you missed a semicolon and it also had shows you how to fix it with its like green underscore and then I believe if I have X climb fixit's that will do something I hope except CVP and actually fix it right so this is really cool so the client already supports us and if you add a little bit of effort you can also support those on your own client tools so this is pretty cool all right and so we have ten minutes left I think I like to use this just for any questions you have on clang tooling or I love um in general yes yes yes the question was like how rapidly does ellipse tooling API change it changes to the extent that any tutorial fine online is not going to compile like like everything from a year ago like every like like Eli render ski has lots of cool tutorials on clan but nothing compels like it's all broken because something has changed in the east in these like AST some method doesn't work anymore or something like this ass matching was only added like in the last two years or something sore anything before that it's not going to work or use it like old methods so very rapidly um yeah not sure there's best practices like I would just say I mean if you have time just like always try to keep it up-to-date with the trunk version like in this case here this is a like line 4.0 which is already available and like if I think it's like like with your normal source code like if you just stick to some compiler for like half a year and then because it supports the standard you want then just it's going to be fine for that compiler because nothing ever changes anytime yeah like if you I mean if you're lucky those versions are going to be more or less the same otherwise I'm sure you could figure out like maybe maybe I have to do some nice stuff otherwise I'm sure there's a standard way around it and because they're imagined mostly things were added I have since then so I would hope that it still works again it shouldn't be too hard isn't yes yes any more questions no question otherwise I do have one few actual slides one is about clangy so climby is a very new project like I just heard of straight from LVM conference a few months ago or a few weeks ago clangy is going to be a language server so that's actually very cool it's maybe in editor agnostic background demon that runs on your system and that different editors like Eclipse or atom or Xcode or Visual Studio or whatever you use can actually communicate with and it's actually very important because what clanky will allow you to do is like make I don't know RPC calls or something like that a communicative socket and get code completion get indexing get linting get formatting like basically get clang as a service on your system and that's gonna be pretty big at the same time it's like I mean it's I was gonna say somewhere near stable they actually already have quite a few things like you have code completion they have linting right now they're faking out the indexing strategy but yet so it's still working progress and if you if you're interested in just talk to me and I will point you in directions yes yeah the Microsoft ya the Microsoft server language server protocol it's an implementation of that yeah so it's very early development like there's just one or two guys working on it but it's very promising and so and so if you want to help out and please do and then also like how do I continue so that this talk was not necessarily about me being an expert but me just likes for sharing the learning experience I also wanted like point you know some directions at one point is Eli burned risky's logs so this is a Googler working on the tensorflow team actually he works on this this compiler using LLVM that compels the computational graphs for tensor flow but he also has loads of posts on plan and LEM which are very interesting and then like I would say LVM and Klein Eternals so there's actually even though the in line source documentation is not too extensive there's lots of resources externally like so before you saw this this programmers manual like there's just like a whole document on everything about learning how to use LLVM there's the same thing for clang there's the same things were like a smashing so just like either those resources then there's this log by a person that may be me and that has some blog post and clang and also going to put all these other tools that I have here up online so you can use them and just like you pull the docker it should take like three minutes and then you can try out all these different tools and they're all documented so you can see what they do and maybe take it from there for your own tool and then a source code so as you saw I'm very excited about the client source code it's very very nice code I use a very like the people working on it are extreme smart and extremely performance / paranoid so like it's very educational to look at the code and see how they do it and maybe also fix all the things they did wrong and they yeah so I know the sites are given B yet there later on including the code and and the server if you want to like look at my service counselor Pizza okay thanks those are going to be Q&A I think we can skip that um yeah thanks [Applause]
Info
Channel: CppNow
Views: 26,321
Rating: 4.9494948 out of 5
Keywords: Peter Goldsborough, C++Now 2017, Computer Science (Field), + C (Programming Language), Bash Films, conference video recording services, conference recording services, nationwide conference recording services, conference videography services, conference video recording, conference filming services, conference services, conference recording, conference live streaming, event videographers, capture presentation slides, record presentation slides, event video recording
Id: E6i8jmiy8MY
Channel Id: undefined
Length: 82min 41sec (4961 seconds)
Published: Tue Jun 13 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.