Skip to content
  1. Sep 28, 2017
  2. Jul 17, 2017
    • Faisal Vali's avatar
      [NFC] Refactor the Preprocessor function that handles Macro definitions and... · ac506d74
      Faisal Vali authored
      [NFC] Refactor the Preprocessor function that handles Macro definitions and rename Arguments to Parameters in Macro Definitions. 
        - Extracted the reading of the tokens out into a separate function.
        - Replace 'Argument' with 'Parameter' when referring to the identifiers of the macro definition (as opposed to the supplied arguments - MacroArgs - during the macro invocation).
      
      This is in preparation for submitting patches for review to implement __VA_OPT__ which will otherwise just keep lengthening the HandleDefineDirective function and making it less comprehensible.
      
      I will also directly update some extra clang tooling that is broken by the change from Argument to Parameter.
      
      Hopefully the bots will stay appeased.
      
      Thanks!
      
      llvm-svn: 308190
      ac506d74
    • Faisal Vali's avatar
      Revert changes from my previous refactoring - will need to fix dependencies in... · 0e54e567
      Faisal Vali authored
      Revert changes from my previous refactoring - will need to fix dependencies in clang's extra tooling (such as clang-tidy etc.).
      
      Sorry about that.
      
      llvm-svn: 308158
      0e54e567
    • Faisal Vali's avatar
      [NFC] Refactor the Preprocessor function that handles Macro definitions and... · 11746b05
      Faisal Vali authored
      [NFC] Refactor the Preprocessor function that handles Macro definitions and rename Arguments to Parameters in Macro Definitions. 
        - Extracted the reading of the tokens out into a separate function.
        - Replace 'Argument' with 'Parameter' when referring to the identifiers of the macro definition (as opposed to the supplied arguments - MacroArgs - during the macro invocation).
      
      This is in preparation for submitting patches for review to implement __VA_OPT__ which will otherwise just keep lengthening the HandleDefineDirective function and making it less comprehensible.
      
      
      Thanks!
      
      llvm-svn: 308157
      11746b05
  3. Jun 15, 2017
    • Erich Keane's avatar
      [Preprocessor]Correct Macro-Arg allocation of StringifiedArguments, · 8691d6e6
      Erich Keane authored
      correct getNumArguments
      
      StringifiedArguments is allocated (resized) based on the size the 
      getNumArguments function. However, this function ACTUALLY currently 
      returns the amount of total UnexpArgTokens which is minimum the same as 
      the new implementation of getNumMacroArguments, since empty/omitted arguments 
      result in 1 UnexpArgToken, and included ones at minimum include 2 
      (1 for the arg itself, 1 for eof).
      
      This patch renames the otherwise unused getNumArguments to be more clear 
      that it is the number of arguments that the Macro expects, and thus the maximum 
      number that can be stringified. This patch also replaces the explicit memset 
      (which results in value instantiation of the new tokens, PLUS clearing the 
      memory) with brace initialization.
      
      Differential Revision: https://reviews.llvm.org/D32046
      
      llvm-svn: 305425
      8691d6e6
  4. Apr 30, 2015
    • Richard Smith's avatar
      [modules] Stop trying to fake up a linear MacroDirective history. · 20e883e5
      Richard Smith authored
      Modules builds fundamentally have a non-linear macro history. In the interest
      of better source fidelity, represent the macro definition information
      faithfully: we have a linear macro directive history within each module, and at
      any point we have a unique "latest" local macro directive and a collection of
      visible imported directives. This also removes the attendent complexity of
      attempting to create a correct MacroDirective history (which we got wrong
      in the general case).
      
      No functionality change intended.
      
      llvm-svn: 236176
      20e883e5
  5. Nov 08, 2014
  6. Oct 25, 2014
    • David Majnemer's avatar
      Lex: Fix an invalid access into a SmallString · d3c3e78a
      David Majnemer authored
      We would crash because we used operator[] to access past the end of a
      SmallString.  This occured because our token had length zero.
      
      Instead, form the pointer using .data() and arithmetic.  This is safe
      because this forms a one-past-the-end pointer and it is only used to
      compare with another one-past-the-end pointer.
      
      This fixes PR21379.
      
      llvm-svn: 220614
      d3c3e78a
  7. May 18, 2014
  8. May 09, 2014
  9. May 04, 2013
  10. Mar 10, 2013
  11. Jan 12, 2013
  12. Dec 04, 2012
    • Chandler Carruth's avatar
      Sort all of Clang's files under 'lib', and fix up the broken headers · 3a02247d
      Chandler Carruth authored
      uncovered.
      
      This required manually correcting all of the incorrect main-module
      headers I could find, and running the new llvm/utils/sort_includes.py
      script over the files.
      
      I also manually added quite a few missing headers that were uncovered by
      shuffling the order or moving headers up to be main-module-headers.
      
      llvm-svn: 169237
      3a02247d
  13. Sep 24, 2012
  14. Apr 03, 2012
    • Argyrios Kyrtzidis's avatar
      Correct handling of _Pragma macro inside a macro argument. · f1b64c61
      Argyrios Kyrtzidis authored
      If we are pre-expanding a macro argument don't actually "activate"
      the pragma at that point, activate the pragma whenever we encounter
      it again in the token stream.
      This ensures that we will activate it in the correct location
      or that we will ignore it if it never enters the token stream, e.g:
      
           \#define EMPTY(x)
           \#define INACTIVE(x) EMPTY(x)
           INACTIVE(_Pragma("clang diagnostic ignored \"-Wconversion\""))
      
      This also fixes the crash in rdar://11168596.
      
      llvm-svn: 153959
      f1b64c61
  15. Feb 05, 2012
  16. Feb 04, 2012
  17. Oct 03, 2011
  18. Sep 22, 2011
  19. Sep 04, 2011
  20. Jul 27, 2011
  21. Jul 07, 2011
    • Argyrios Kyrtzidis's avatar
      Make the Preprocessor more memory efficient and improve macro instantiation diagnostics. · 41fb2d95
      Argyrios Kyrtzidis authored
      When a macro instantiation occurs, reserve a SLocEntry chunk with length the
      full length of the macro definition source. Set the spelling location of this chunk
      to point to the start of the macro definition and any tokens that are lexed directly
      from the macro definition will get a location from this chunk with the appropriate offset.
      
      For any tokens that come from argument expansion, '##' paste operator, etc. have their
      instantiation location point at the appropriate place in the instantiated macro definition
      (the argument identifier and the '##' token respectively).
      This improves macro instantiation diagnostics:
      
      Before:
      
      t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int')
      int y = M(/);
              ^~~~
      t.c:5:11: note: instantiated from:
      int y = M(/);
                ^
      
      After:
      
      t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int')
      int y = M(/);
              ^~~~
      t.c:3:20: note: instantiated from:
      \#define M(op) (foo op 3);
                      ~~~ ^  ~
      t.c:5:11: note: instantiated from:
      int y = M(/);
                ^
      
      The memory savings for a candidate boost library that abuses the preprocessor are:
      
      - 32% less SLocEntries (37M -> 25M)
      - 30% reduction in PCH file size (900M -> 635M)
      - 50% reduction in memory usage for the SLocEntry table (1.6G -> 800M)
      
      llvm-svn: 134587
      41fb2d95
  22. Apr 28, 2011
  23. Mar 16, 2010
  24. Dec 28, 2009
  25. Dec 23, 2009
  26. Dec 15, 2009
    • Chris Lattner's avatar
      enable reuse of MacroArgs objects. This is a small (2.5%) win · 1316249a
      Chris Lattner authored
      on PR5610 (2.185 -> 2.130s).  The big issue is that this is making
      insanely huge macro argument lists with over a million tokens in it.
      The reason that mallco and free are so expensive is that we are 
      actually going to the kernel to get it, and switching to a bump 
      pointer allocator won't change this in an interesting way.
      
      llvm-svn: 91449
      1316249a
    • Chris Lattner's avatar
      set up the machinery for a MacroArgs cache hanging off Preprocessor. · d19564b1
      Chris Lattner authored
      We creating and free thousands of MacroArgs objects (and the related
      std::vectors hanging off them) for the testcase in PR5610 even though
      there are only ~20 live at a time.  This doesn't actually use the 
      cache yet.
      
      llvm-svn: 91391
      d19564b1
  27. Dec 14, 2009
  28. Sep 09, 2009
  29. May 13, 2009
  30. Jan 29, 2009
  31. Jan 27, 2009
  32. Jan 26, 2009
    • Chris Lattner's avatar
      remove my hacks that aggressively threw away multiple · 357b57d7
      Chris Lattner authored
      instantiation history in an effort to speed up c99-intconst-1.c.
      Now that multiple nested instantiations are allowed, we just
      make them and don't pay the cost of lookups.  With the other
      changes that went in before this, reverting this is actually
      a speedup for c99-intconst-1.c, speeding it up from 1.96s to 1.80s,
      and preserves much better loc info.
      
      llvm-svn: 63036
      357b57d7
    • Chris Lattner's avatar
      This change refactors some of the low-level lexer interfaces a bit. · 5a7971e0
      Chris Lattner authored
      Token now has a class of kinds for "literals", which include 
      numeric constants, strings, etc.  These tokens can optionally have
      a pointer to the start of the token in the lexer buffer.  This 
      makes it faster to get spelling and do other gymnastics, because we
      don't have to go through source locations.
      
      This change is performance neutral, but will make other changes
      more feasible down the road.
      
      llvm-svn: 63028
      5a7971e0
    • Chris Lattner's avatar
      eagerly resolve the spelling locations of macro argument preexpansions. · ad13cf4e
      Chris Lattner authored
      This reduces fsyntax-only time on c99-intconst-1.c from 2.43s down to 
      2.01s (20%), reducing the number of fileid lookups from 2529040 linear 
      and 64771121 binary to 5625902 linear and 4151182 binary.
      
      This knocks getFileID down to only 4.6% of compile time on this testcase.
      At this point, malloc/free is over 35% of compile time, primarily allocating
      MacroArgs objects and their argument preexpansion vectors.
      
      I don't feel like malloc avoiding right now, so I'm just going to call
      this good.
      
      llvm-svn: 62994
      ad13cf4e
Loading