[-cxx-abi microsoft] Implement local manglings accurately

Press ? to show keyboard shortcuts.
Committed
majnemerMar 5 2014, 12:57 AM
Reviewer
rnk
Differential Revision
D2953: [-cxx-abi microsoft] Implement local manglings accurately
Parents
rL202950: Increase threshold in StackTrace::LocatePcInTrace
Branches
Unknown
Tags
Unknown
Subscribers
None
Description

[-cxx-abi microsoft] Implement local manglings accurately

Summary:
The MSVC ABI appears to mangle the lexical scope into the names of
statics. Specifically, a counter is incremented whenever a scope is
entered where things can be declared in such a way that an ambiguity can
arise. For example, a class scope inside of a class scope doesn't do
anything interesting because the nested class cannot collide with
another nested class.

There are problems with this scheme:

  • It is unreliable. The counter is only incremented when a previously never encountered scope is entered. There are cases where this will cause ambiguity amongst declarations that have the same name where one was introduced in a deep scope while the other was introduced right after in the previous lexical scope.
  • It is wasteful. Statements like: {{{{{{{ static int foo = a; }}}}}}} will make the mangling of "foo" larger than it need be because the scope counter has been incremented many times.

Because of these problems, and practical implementation concerns. We
choose not to implement this scheme if the local static or local type
isn't visible. The mangling of these declarations will look very
similar but the numbering will make far more sense, this scheme is
lifted from the Itanium ABI implementation.

Reviewers: rsmith, doug.gregor, rnk, eli.friedman, cdavis5x

Reviewed By: rnk

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D2953

rL202951

cfe/trunk/include/clang/AST/ASTContext.h

Loading...

cfe/trunk/include/clang/AST/Mangle.h

Loading...

cfe/trunk/include/clang/AST/MangleNumberingContext.h

Loading...

cfe/trunk/include/clang/Parse/Parser.h

Loading...

cfe/trunk/include/clang/Sema/Scope.h

Loading...

cfe/trunk/lib/AST/ASTContext.cpp

Loading...

cfe/trunk/lib/AST/ItaniumCXXABI.cpp

Loading...

cfe/trunk/lib/AST/ItaniumMangle.cpp

Loading...

cfe/trunk/lib/AST/MangleNumberingContext.cpp

Loading...

cfe/trunk/lib/AST/MicrosoftCXXABI.cpp

Loading...

cfe/trunk/lib/AST/MicrosoftMangle.cpp

Loading...

cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Loading...

cfe/trunk/lib/Parse/ParseStmt.cpp

Loading...

cfe/trunk/lib/Sema/Scope.cpp

Loading...

cfe/trunk/lib/Sema/SemaDecl.cpp

Loading...

cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Loading...

cfe/trunk/test/CodeGenCXX/mangle-ms-abi-examples.cpp

Loading...

cfe/trunk/test/CodeGenCXX/microsoft-abi-static-initializers.cpp

Loading...

Add Comment