1. 27 Feb, 2015 1 commit
  2. 17 Feb, 2015 1 commit
    • Adam Strzelecki's avatar
      C++: Basic support for C++11 user-defined literals · 42581129
      Adam Strzelecki authored
      
      
      1. Extends lexer so digit or string can be followed by underscore '_' and
         alphanumeric defining literal.
      
      2. Extends parser so it accepts operator"" _abc(...) user-defined literal
         definition.
      
      3. Adds Token::Flags.userDefinedLiteral bool flag field representing if token
         carries user-defined literal.
      
      4. Adds C++11 auto tests case with: 12_km, 0.5_Pa, 'c'_X, "abd"_L, u"xyz"_M
      
      5. All optional suffix scanning methods now return boolean if the suffix was
         found.
      
      6. Adds C++ Lexer tests for user-defined literals with C++11 feature enabled.
      
      This change however does not make QtCreator understand user-defined literal
      semantics, e.g. properly resolve type when applying custom literal operator.
      
      Change-Id: I30e62f025ec9fb11c39261985ea4d772b1a80949
      Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
      42581129
  3. 12 Feb, 2015 2 commits
    • Nikolai Kosjar's avatar
      C++: Cache parsing of template ids · 921ec6da
      Nikolai Kosjar authored
      
      
      ...in order to stop memory intensive parsing for invalid code.
      
      Parsing the test data/snippet "hard" led to a memory consumption of
      about 5.5MB and this could easily get up to hundreds/gigabytes by adding
      some more "if_<bool_<true>,\n" lines. With the caching, we are at about
      1.0MB, even if more lines are added.
      
      The "memory consumption" was measured with valgrind-massif. The stated
      numbers are the reported peaks.
      
      Task-number: QTCREATORBUG-12890
      Change-Id: Ie7eb00cfc7915552d29bb27410a6b13a486f486e
      Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
      921ec6da
    • Nikolai Kosjar's avatar
      C++: Remove workaround for crashing if parsing invalid code · ae3aa07c
      Nikolai Kosjar authored
      This reverts the changes
      
          commit beac7b95
          C++: Fix highlighting after "invalid code"
      
          commit 78ab287f
      
      
          C++: Stop parsing a declaration after two tries
      
      which were a work around for QTCREATORBUG-12890.
      
      A follow-up patch provides a proper fix.
      
      Task-number: QTCREATORBUG-12890
      Change-Id: I2650a8e41c8ff1180cad9f069e463fc51bd2f1b1
      Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
      ae3aa07c
  4. 19 Nov, 2014 1 commit
    • Nikolai Kosjar's avatar
      C++: Fix highlighting after "invalid code" · beac7b95
      Nikolai Kosjar authored
      
      
      For the semantic info document we do not expand function like macros and
      because of that certain macro invocations lead to invalid code that we
      need to handle, e.g.:
      
      	Q_GLOBAL_STATIC(CppTools::SymbolFinder, symbolFinder)
      	class Foo {};
      
      This change makes parsing Foo in the semantic info document successfully
      again, which affects highlighting of that class.
      
      Change-Id: I389265ac64d3f0b8b8f406d38fa58d78820b14ba
      Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
      beac7b95
  5. 18 Nov, 2014 1 commit
    • Nikolai Kosjar's avatar
      C++: Stop parsing a declaration after two tries · 78ab287f
      Nikolai Kosjar authored
      
      
      If we fail to parse a declaration, we rewind, eat the token and look for the
      next token that might be a good candidate for a declaration start (e.g. an
      identifier). This becomes cpu and memory expensive with super long and invalid
      expressions like
      
          typedef b::m::if_< b::m::bool_<
      	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<70> *) 0)) ==
      	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
      	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<71> *) 0)) ==
      	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
      	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<72> *) 0)) ==
      	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
      	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<73> *) 0)) ==
      	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
      	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<74> *) 0)) ==
      	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
      	(sizeof(fun((Dummy *) 0, (ThisT *) 0, (b::m::int_<75> *) 0)) ==
      	 sizeof(defined_)) >, b::m::if_< b::m::bool_<
      	// ...some more crazy lines like this
      
      Therefore, stop trying after two failures by looking for the next semicolon or
      closing curly brace.
      
      Task-number: QTCREATORBUG-12890
      Change-Id: I6637daeb840dd549d669080775228fa91fc932eb
      Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
      78ab287f
  6. 15 Oct, 2014 1 commit
    • Nikolai Kosjar's avatar
      C++: Fix parsing of "Foo *foo = new Foo()" · 390b4f0e
      Nikolai Kosjar authored
      It should be parsed as an DeclarationStatement, but instead it was
      parsed as an ExpressionStatement.
      
      Regression introduced with
      
          commit d3c5fff6
      
      .
          C++: Fix expensive parsing of expressions
      
      The introduced ASTCache did not save the correct return value of a
      parse* function. Because of that, the first return in
      Parser::parseExpressionList returned false on the second invocation
      (cache hit), instead of true, which resulted in an ExpressionStatement.
      
      Task-number: QTCREATORBUG-13122
      Change-Id: I8dbd8852b0909edddcd3195b484f4cea92328cc5
      Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
      390b4f0e
  7. 12 Sep, 2014 1 commit
  8. 05 Aug, 2014 1 commit
  9. 24 Jul, 2014 2 commits
    • Nikolai Kosjar's avatar
      C++: Fix expensive parsing of expressions · d3c5fff6
      Nikolai Kosjar authored
      
      
      For expression statements like "(g(g(g(...(g(0))...))))" we reparsed
      quite much again and again for nothing. The high-level trace for this
      expression looks like this:
      
          parseCastExpression
            parseTypeId
              parseAbstractDeclarator
                parseAbstractCoreDeclarator
                parseParameterDeclarationClause (--> DEEP)
                  ...
      
            parseUnaryExpression
              ...
              parseCorePostfixExpression
                parseTypeId (--> DEEP)
                parsePrimaryExpression (--> DEEP)
      
      Especially parseTypeId is expensive in this case and it's called two
      times, both from the same token (index).
      
      With this patch, we remember for certain ASTs the parse results and
      re-use them when needed.
      
      Change-Id: I013d1c064c655636bc94db408097863b5e183fc2
      Task-number: QTCREATORBUG-12252
      Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
      d3c5fff6
    • Nikolai Kosjar's avatar
      C++: Remove superfluous declarations in Parser · 20108a3d
      Nikolai Kosjar authored
      
      
      Change-Id: I6bf729a999494a84eb235a891ea14bbccd44aeb8
      Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
      20108a3d
  10. 22 Jul, 2014 2 commits
    • Erik Verbruggen's avatar
      C++: Support alignas in C++11 mode. · 45b1169d
      Erik Verbruggen authored
      
      
      Change-Id: Ifa81a481bf92b5b71495a105ae292f3e9895f704
      Task-number: QTCREATORBUG-9279
      Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
      45b1169d
    • Erik Verbruggen's avatar
      C++: block recursion when parsing subsequent case statements. · 5d45e0b6
      Erik Verbruggen authored
      
      
      A case or a default statement must be followed by another statement.
      When a such a case (or default) statement is followed immediately by
      another case (or default) statement, then this would create a linked
      list, and the parser will recurse to parse such input.
      
      In order to prevent the parser running out of stack space while
      recursing, parse this corner case by blocking parsing a labeled
      statement as the first statement after a labeled statement.
      
      The advantage is that these statements do not form a linked list, so any
      subsequent visitation of the AST won't run out of stack space either.
      
      Change-Id: Id2111a49509132997f5fbe4bb12c92c729ec2522
      Task-number: QTCREATORBUG-12673
      Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
      5d45e0b6
  11. 04 Jul, 2014 1 commit
  12. 24 Jun, 2014 2 commits
  13. 17 Jun, 2014 1 commit
    • Wang Hoi's avatar
      C: Parser: Support parsing of c99 designated initializers · c56b999f
      Wang Hoi authored
      
      
      In case:
      
          int a[6] = { [4] = 29, [2] = 15 };
          struct point { int x, y; };
          struct point p = { .y = 3, .x = 2 };
      
      Grammar change when c99 language feature is enabled:
      old grammar:
      
          braced-init-list :: '{' initializer-list '}'
      
      new grammar:
      
          braced-init-list :: '{' designated-initializer-list '}'
          designated-initializer-list :: designated-initializer (',' designated-initializer )*
          designated-initializer :: designator* initializer-clause
          designator :: '.' identifier
                      | '[' constant-expression ']'
      
      Task-number: QTCREATORBUG-1902
      Change-Id: Ib99d6f553f8d0f50ba3eff86f3a2e86d73372426
      Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
      c56b999f
  14. 16 Jun, 2014 1 commit
  15. 12 Jun, 2014 1 commit
  16. 06 Jun, 2014 1 commit
  17. 04 Jun, 2014 1 commit
  18. 13 Mar, 2014 1 commit
  19. 20 Jan, 2014 2 commits
  20. 26 Nov, 2013 1 commit
  21. 12 Nov, 2013 1 commit
  22. 15 Oct, 2013 1 commit
  23. 09 Oct, 2013 1 commit
  24. 21 Aug, 2013 1 commit
  25. 19 Jul, 2013 1 commit
  26. 06 Jun, 2013 1 commit
  27. 19 Apr, 2013 1 commit
  28. 18 Apr, 2013 1 commit
  29. 15 Apr, 2013 2 commits
  30. 09 Apr, 2013 1 commit
  31. 16 Jan, 2013 1 commit
  32. 08 Jan, 2013 2 commits
    • Francois Ferrand's avatar
      C++: fix constructor definition parsing. · 5e8c3f4b
      Francois Ferrand authored
      
      
      When a constructor is defined with a single, unnamed argument of a custom type without
      extra type specifiers (const...), then the constructor was not identified as such.
      There was an heuristic in case the constructor was in the class definition, but not if the
      the constructor was defined later.
      
      Examples:
      
      class Arg;
      class Other;
      
      class Foo {
        Foo(Arg /*arg*/);               // working
        Foo(const Arg /*arg*/);         // working
        Foo(int /*arg*/);               // working
        Foo(Other /*arg*/)         {}   // working
      };
      
      Foo::Foo(Arg /*arg*/)        {}   // used not to work, fixed
      Foo::Foo(Arg arg){}               // working
      Foo::Foo(const Arg /*arg*/)  {}   // working
      Foo::Foo(int arg)            {}   // working
      
      Change-Id: I741e4ba62672ddc99a837fdcdc27996fba5ae6c7
      Reviewed-by: default avatarhjk <qthjk@ovi.com>
      5e8c3f4b
    • Orgad Shaneh's avatar
      Remove braces for single lines of conditions · 29a93998
      Orgad Shaneh authored
      
      
      #!/usr/bin/env ruby
      
      Dir.glob('**/*.cpp') { |file|
        # skip ast (excluding paste, astpath, and canv'ast'imer)
        next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
        s = File.read(file)
        next if s.include?('qlalr')
        orig = s.dup
        s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
          res = $&
          if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
            res
          else
            res.gsub!('} else', 'else')
            res.gsub!(/\n +} *\n/m, "\n")
            res.gsub(/ *{$/, '')
          end
        }
        s.gsub!(/ *$/, '')
        File.open(file, 'wb').write(s) if s != orig
      }
      
      Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
      Reviewed-by: default avatarhjk <qthjk@ovi.com>
      29a93998
  33. 28 Nov, 2012 1 commit